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?
$('#ALL').attr('onclick', 'checkall()')isn't the proper way to add an event listener, if you're using jQuery then use it and don't dodocument.getElementById('ALL').value = "UnCheck All";, and.attr('checked','checked')should be.prop('checked',true)