javascript - displaying image onclick working fine, but how do I hide it on click again -
so have html , javascript code pops image on click of button, , working fine. when image pops up.. cannot close wherever click in page. there javascript function allow un-display on click again
here code
<script type="text/javascript"> function openimage(){ document.getelementbyid('loadingimage').style.visibility="visible"; } </script>
#button { -webkit-border-radius: 28; -moz-border-radius: 28; border-radius: 28px; font-family: arial; color: #ffffff; font-size: 20px; background: transparent; border: solid #ffffff 2px; text-decoration: none; }
<button id="button" onclick="openimage();">get started</button> <img id="loadingimage" src="png/module.png" style="visibility:hidden"/>
function openimage(){ if ( document.getelementbyid('loadingimage').style.visibility == "visible" ) { document.getelementbyid('loadingimage').style.visibility="hidden"; } else { document.getelementbyid('loadingimage').style.visibility="visible"; }
(for sake of clarity , debugging, might want change function name openimage() toggleimage() )
Comments
Post a Comment