Skip to main content

Bug Tracker

Side navigation

#8731 closed bug (worksforme)

Opened March 31, 2011 07:14PM UTC

Closed March 31, 2011 07:59PM UTC

:checked pseudo selector returns duplicate elements for JavaScript-checked input checkboxes

Reported by: Owned by:
Priority: low Milestone:
Component: unfiled Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:


I create an input checkbox - say with id "test" then check it manually. If I evaluate $('#test:checked').length, I will get 1. However, if I use JavaScript to check the checkbox, say with $('#test').attr('checked', true), then $('#test:checked').length will return 2.

Attachments (0)
Change History (1)

Changed March 31, 2011 07:59PM UTC by addyosmani comment:1

priority: undecidedlow
resolution: → worksforme
status: newclosed

Thanks for submitting a ticket to the jQuery Bug Tracker. I've created a minimal test case based on the information you've provided us with, but whether checked is initially set and changed using attr() later on or unset and adjusted, both cases appear to be working fine with the length being returned correctly. See here for the minimal test: