Delete <p> element in form submit event - Javascript DOM

Javascript examples for DOM:Event

Description

Delete <p> element in form submit event

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script>
        function removeP2() {//from  ww w. j a  v a  2 s . c  o  m
            document.getElementById("p2").remove();
        }
        
      </script>  
      <nav> 
         <form method="POST" onsubmit="removeP2(); return false;"> 
            <button>Remove</button> 
         </form> 
      </nav> 
      <section id="section"> 
         <p id="p1">Paragraph One.</p> 
         <p id="p2">Paragraph Two.</p> 
      </section>   
   </body>
</html>

Related Tutorials