Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
50
rated 0 times [  53] [ 3]  / answers: 1 / hits: 44878  / 11 Years ago, mon, april 8, 2013, 12:00:00

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:



http://jsfiddle.net/priyam/K9P8A/



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


More From » jquery

 Answers
22

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


[#79044] Sunday, April 7, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bradleymoisesy

Total Points: 121
Total Questions: 105
Total Answers: 95

Location: Nepal
Member since Mon, Jan 4, 2021
3 Years ago
;