javascript - Show/Hide element when clicking buttons -


i have 2 buttons show , hide , have image want know when click hide button img disappear , when click show button appear again. , don't want css or jquery javascript. if can lot.

window.onload = function(){    var myimg = document.getelementbyid('myimg');        document.getelementbyid('hidebtn').onclick = function(){        myimg.style.display = 'none';    };        document.getelementbyid('showbtn').onclick = function(){        myimg.style.display = '';    };        document.getelementbyid('togglebtn').onclick = function(){        var display = getcomputedstyle(myimg).display=='none'?'':'none';        myimg.style.display = display;    };  }
<button id="hidebtn">hide</button>  <button id="showbtn">show</button>  <button id="togglebtn">toggle</button>  <br/>  <img id="myimg" src="http://www.eastcottvets.co.uk/uploads/animals/gingerkitten.jpg" alt="" />


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -