Making a button invisible by clicking another button in HTML

Nasrin hakim Mithila picture Nasrin hakim Mithila · Dec 19, 2011 · Viewed 101.4k times · Source

How can I make a button invisible by clicking another button in HTML?
I have written like below, but it doesn't work.

<input type="button" onclick="demoShow();" value="edit" />
<script type="text/javascript"> 
    function demoShow()
    { document.getElementsByName('p2').style.visibility="hidden"; }
</script>
<input id="p2" type="submit" value="submit" name="submit" />

Answer

Sonal Khunt picture Sonal Khunt · Dec 19, 2011

write this

To hide

{document.getElementById("p2").style.display="none";}

to show

{document.getElementById("p2").style.display="block";}