Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select All Checkboxes By ID/Class

Tags:

javascript

I'm really bad at Javascript and I'm struggling to get my head round it.

What I'm trying to do is get something to select all checkboxes. However everything I have found tries to do it by name, I want to do it by ID or class. Select all by name is just inpractical isn't it?

like image 251
Ben Shelock Avatar asked Jun 23 '09 14:06

Ben Shelock


1 Answers

Using JQuery, you can do this very easilly!

$(".ClassName").attr("checked", "true");

or a single ID

$("#ID").attr("checked", "true");

See: Check All Checkboxes with JQuery.

like image 176
Andrea Avatar answered Sep 28 '22 08:09

Andrea