Show a hidden div when a checkbox is clicked using jQuery - Javascript jQuery

Javascript examples for jQuery:Mouse Event

Description

Show a hidden div when a checkbox is clicked using jQuery

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.4.2.js"></script> 
  <script type="text/javascript">
$(function(){/*  w ww . j a v  a 2s . c o  m*/
   $('.toggler').click(function(){
       $('div#name').toggle(this.checked);
   });
})

      </script> 
 </head> 
 <body> 
  <div id="name">
    I'm a div 
  </div> 
  <input type="checkbox" name="myCB" value="A" class="toggler" checked> show/hide above  
 </body>
</html>

Related Tutorials