Skip to main content

Bug Tracker

Side navigation

#13876 closed bug (duplicate)

Opened May 10, 2013 05:01AM UTC

Closed May 10, 2013 03:31PM UTC

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:
Description

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);

}

});

Attachments (0)
Change History (3)

Changed May 10, 2013 05:13AM UTC by ulrik comment:1

Changed May 10, 2013 06:00AM UTC by ruado1987 comment:2

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

Changed May 10, 2013 03:31PM UTC by timmywil comment:3

resolution: → duplicate
status: newclosed

Duplicate of #13245.