JQuery change checkbox button text when clicked - Javascript jQuery

Javascript examples for jQuery:Form Checkbox

Description

JQuery change checkbox button text when clicked

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.4.min.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/*w ww . j a v  a2 s  .co  m*/
$("#button").click(function() {
    $("#label").text(this.checked ? "Hide" : "Show");
});
    });

      </script> 
 </head> 
 <body> 
  <input id="button" type="checkbox"> 
  <label id="label" for="button">Show/Hide</label>  
 </body>
</html>

Related Tutorials