sidhewsar sidhewsar - 1 year ago 78
HTML Question

how to show or hide a div on button click using javascript

here the following are the codes

<style type="text/css">
#mydiv{ margin:0 auto;padding:0;width:250px;height:100px; border:1px solid threedshadow;display:none;}

<script type="text/javascript">
function show()
var div=document.getElementById('mydiv'); == "none" ? "block" : "none";

<input type="button" onclick="show()" value="show"/>
<div id="mydiv">

this code does not working can anybody help me!!

Answer Source

Close, but you're not assigning the display value to the display property. Try this: = ( == "none") ? "block" : "none";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download