Reputation: 73
how can i access div element from javascript. i am doing the code in asp.net. i want to make the div visible after clicking on a button.
the visibility code is given as follows:
i am getting an error :
BC30451: 'data1' is not declared. It may be inaccessible due to its protection level.
Javascript
var div = document.getElementById("<%=data1.ClientID %>");
div.style.visibility = 'visible';
Aspx
<div id="data1" class="division" style="visibility: hidden">
</div>
Upvotes: 0
Views: 67
Reputation: 6586
Add runat=server
and you can do it the way you have posted.
<div id="data1" class="division" style="visibility: hidden" runat="server">
</div>
Upvotes: 1