Priyam Priyam - 1 year ago 111
HTML Question

Jquery "select all" checkbox

I am trying to select all checkboxes on a page once the 'select all' checkbox is clicked and i am using jquery for this as you can see at the below link:

The code to select and unselect all checkbox is:

function selectAll() {
$('.selectedId').attr('checked', isChecked('selectall'));

function isChecked(checkboxId) {
var id = '#' + checkboxId;
return $(id).is(":checked");

After being stuck with it for a day, I am still not sure why I cant get it to work. Please help

Answer Source

Your fiddle works after I made 3 fixes :

  • import of jQuery (top left menu)
  • addition of the missing isChecked function
  • use of prop instead of attr to check the boxes
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download