Possible Duplicate:
Why does jQuery or a DOM method such as `getElementByID` not find the element?
Apologize for the silly question, but I am not getting what I want.
I am using following code to change visibility of table.
<script type="text/javascript">
document.getElementById('<%= tblEnablePreferredZerker.ClientID %>').style.display = "none";
</script>
<table class="style1" id="tblEnablePreferredZerker" >
<tr></tr>
</table>
Is there any mistake? or any other method to do this?
Or can it be easily possible with jQuery?
Thanks,
You are trying to access this id of table with ClientID which is not server accessible, You need to add runat=”server” in table tag.
You are
trying to access the element that is not yet available. Put your script just after the table you are try to access or before theclosing body tagso that you have every html element ready before use. You can also usedocument.readyjquery event if you want to place before your html element.Putting script below the element you want to access.
Putting script just before closing of body tag
Using jQuery document.ready