In jQuery, the attr('checked') function is not used to check the checked property of a checkbox. Instead, you can use the following methods:
The checked property of the checkbox DOM element provides the checked state of the checkbox:
if (document.getElementById('isAgeSelected').checked) { $("#txtAge").show(); } else { $("#txtAge").hide(); }
When the checkbox is clicked, the change() event is triggered. You can use it to toggle the visibility of the text box:
$('#isAgeSelected').click(function () { $("#txtAge").toggle(this.checked); });
The above is the detailed content of How to Check Checkbox Status in jQuery?. For more information, please follow other related articles on the PHP Chinese website!