Tick All Checkboxes With Vanilla JavaScript or jQuery

Here for me to copy/paste as-needed… feel free to do the same 💁‍♂️

Vanilla JavaScript

var inputs=document.getElementsByTagName('input');for(var i=0;i<inputs.length;i++){if(inputs[i].type=='checkbox'){inputs[i].checked=true;}}

jQuery Equivalent

$('input:checkbox').prop('checked',true);

Happy coding 😀

Leave a Reply

Your email address will not be published.