I'm trying to hide and element inside a form but it's not working. here's my code:
<style> .hide { visibility: hidden; display: none; } </style> </head> <body> <form> <input type="submit" id="show" value="Show" /> <input type="submit" value="Hide" id="hide" /> </form> <script type="text/javascript"> /* save the 2 nodes to variables */ var button = document.getElementById("show"), target = document.getElementById("hide"); /* define what we want to do in a function */ function hide(){ target.setAttribute("class","hide"); } /* add the CSS class when the button is clicked */ button.addEventListener("click", hide, false); </script> </body> - But it works if I take it out of the form container. Please explain...