Showing and Hiding a div - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:fadeToggle

Description

Showing and Hiding a div

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-1.8.3.js"></script> 
  <style id="compiled-css" type="text/css">

#redBox  {width:300px; height:300px; background-color:red;}


      </style> 
  <script type="text/javascript">
    $(window).load(function(){/*  ww w .  jav a  2  s .c  om*/
$('button').click(function() {
    $('#redBox').fadeToggle();
});
    });

      </script> 
 </head> 
 <body> 
  <button>Toggle</button> 
  <div id="redBox"></div>  
 </body>
</html>

Related Tutorials