I have two functions that I have made that check and uncheck all check boxes with a specific class. the first time I run the functions they do as expected but after I try to run the function again the check boxes do not check, but the html code changes.
JQuery...
function checkall() {
$('.column').attr('checked','checked');
$('#ALL').attr('onclick', 'uncheckall()')
document.getElementById('ALL').value = "UnCheck All";
}
after running this I get <input type="checkbox" value="SEQN" class="column" onchange="updatearray()" checked="checked">
function uncheckall() {
$('.column').removeAttr('checked');
$('#ALL').attr('onclick', 'checkall()')
document.getElementById('ALL').value = "Check All";
}
after running this I get <input type="checkbox" value="SEQN" class="column" onchange="updatearray()">
Why do the check-boxes only change once?
尝试使用prop()而不是attr()。如果问题仍然存在,请迭代各个复选框
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.