Hide and show element with toggle() - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:toggle

Description

Hide and show element with toggle()

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script src="https://code.jquery.com/jquery-1.9.1.js"></script> 
   </head> 
   <body> 
      <button>Toggle</button> 
      <p>Hello</p> 
      <p style="display: none">Good Bye</p> 
      <script>
$("button").click(function (){
    $("p").toggle();
});//  w ww.j  a  v a 2  s  .  c om

      </script>  
   </body>
</html>

Related Tutorials