visibility:collapse in javascript

白昼怎懂夜的黑 提交于 2019-12-11 07:41:04

问题


I'm using Ultrawebgrid for my applcation:

I'm using a textarea for listing the errors in my application in the row template when the user clicks that particular row...

So I need to have texarea when there are any errors..... otherwise when there are no errors i dont even want the row_template to pop up..... I'm using IE6.

I'm checking if there are any errors using javascript.so I had to use the javascript event handler:: UltraWebGrid1_BeforeRowTemplateOpenHandler(gridName, rowId, templateId)

where in I write the statements given below: document.getElementById("TextArea2").style.visibility="collapse" inside the above event function

1) it's showing javascript error as "Couldnot get the visibility property:Invalid Argument" but the row template does not pop up....... only the error's coming....

2) Is there any code to block the row template when there are no errors.?? i mean no pop_up for no errors

What's the solution for this???


回答1:


DISPLAY

Use display instead of visibility. This occupies no space in your document.

document.getElementById("TextArea2").style.display = 'none';    // Turn off    
document.getElementById("TextArea2").style.display = 'inline';  // Turn on

VISIBILITY

document.getElementById("TextArea2").style.visibility="hidden";    // Turn off
document.getElementById("TextArea2").style.visibility="visible";    // Turn on

By using the above code textarea won't be visible, but there will be blank space in your document having the height and width of the textarea.

Also 'collapse' value is supported only in Internet Explorer 8




回答2:


Try using:

document.getElementById("TextArea2").style.display = 'none';

and (to turn it back on again)

document.getElementById("TextArea2").style.display = 'block'; // or 'inline'



回答3:


You want:

document.getElementById("TextArea2").style.visibility = "hidden";

"collapse" is not a valid value for the visibility property in IE6, as your error message indicates.

Alternatively as suggested by @tvanoffsen you could set the display property to "none". This has a slightly different effect - it will not take up any space if set to "display: none", whereas setting "visibility: hidden" still takes up space.




回答4:


use visible and hidden for .style.visibility attribute not block and hidden. it works.



来源:https://stackoverflow.com/questions/852321/visibilitycollapse-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!