Bug Tracker

Opened 10 years ago

Closed 10 years ago

#13876 closed bug (duplicate)

Modify attribute of all elements in class

Reported by: ulrik Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:


I checked "select_all", which successfully checked all checkboxes with class "checkbox_read". I then unchecked "select_all" which successfully UNchecked all checkboxes with class "checkbox_read."

Then I checked "select_all", again which failed to check all checkboxes with class "checkbox_read."

I found this bug after upgrading my JQuery library from 1.7.1 to 1.9.1. when I downgraded, the error did not manifest itself.

Code is below:

$('#select_all').click(function() {

if(this.checked) {

$('.checkbox_read').attr('checked', 'checked');

} else {

$('.checkbox_read').attr('checked', false);



Change History (3)

comment:2 Changed 10 years ago by ruado1987

When working with attributes whose value is of boolean type, it is recommended to use prop instead of attr. There is a detailed discussion on their differences in the API documentation. Here is the jsfiddle fork which uses prop instead of attr and it works as expected in jQuery 1.9.1

comment:3 Changed 10 years ago by timmywil

Resolution: duplicate
Status: newclosed

Duplicate of #13245.

Note: See TracTickets for help on using tickets.