Disable a textbox if a checkbox is checked using jQuery - Javascript jQuery

Javascript examples for jQuery:Form Checkbox

Description

Disable a textbox if a checkbox is checked 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.10.0.js"></script> 
  <script type="text/javascript">
$(function () {//  w ww  .j a  v a 2 s . c  o m
    $('.ba').on('change', function () {
        var checked = $(this).prop('checked');
        $('.tex').prop('disabled', !checked);
    });
});

      </script> 
 </head> 
 <body> 
  <input type="checkbox" class="ba" checked> 
  <input type="text" class="tex">  
 </body>
</html>

Related Tutorials