Display A Div On Button Click
I have a div, whose display is set to none. On button click, I need to show this div. I have wrote a JavaScript function to do so, and it works but on click of the button the div i
Solution 1:
If I interpret your question correctly: the div
resets to be hidden on page refresh or navigation. This is to be expected, the display value should be handled on the server side too.
As others have said, the problem is that when you click on the button, the page is posted to the server. If you do not want to do this, you should use a normal HTML button (with type="button"
), instead of an ASP one.
Solution 2:
Your Javascript is working, the Problem seems to be the Button implemented with ASP.
The Problem could be the Serversided implementation of the Button, here is the HTML implementation. Things are working there.
functionshow_popup() {
document.getElementById("Div1").style.display = 'block';
}
<divid="Div1"style="display:none">asdasdasdasdasdasd</div><inputtype="button"onclick="show_popup()"value="Show"></input>
Post a Comment for "Display A Div On Button Click"