sidhewsar sidhewsar - 5 months ago 32
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!!


Close, but you're not assigning the display value to the display property. Try this: = ( == "none") ? "block" : "none";