首页javascripttext_inputjQuery Form - 如何如果选中复选框,请禁用文本框

jQuery Form - 如何如果选中复选框,请禁用文本框

我们想知道如何如果选中复选框,请禁用文本框。

<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.10.0.js'></script>
<script type='text/javascript'>
$(function () {
    $('.ba').on('change', function () {
        var checked = $(this).prop('checked');
        $('.tex').prop('disabled', !checked);
    });
});

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