I try using a jquery to enable a textbox when checked a checkbox. my page jquery:
<script>
$(document).ready(function(){
$('#isNews').change(function(){
$("#newsSource").prop("disabled",false);
});
});
</script>
html:
<label class="checkbox">
<input type="checkbox" id="isNews" name="isNews">If you want send news:
</label>
<label for="newsSource" class="ilable">news source</label>
<input id="newsSource" name="newsSource" class="input-xlarge" disabled="" type="text" placeholder="news source">
what's the problem?
Change to
$('#isNews').change(function(){
$("#newsSource").prop("disabled", !$(this).is(':checked'));
});
Demo: Fiddle
Apart from the error related to non-inclusion of jQuery, change your code to this:
$('#isNews').change(function () {
$("#newsSource").prop("disabled", !this.checked);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With