Bug Tracker

Opened 8 years ago

Closed 8 years ago

#8731 closed bug (worksforme)

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

Reported by: devonnigelreed@… Owned by:
Priority: low Milestone: 1.next
Component: unfiled Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:

Description

Example:

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.

Change History (1)

comment:1 Changed 8 years ago by addyosmani

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: http://jsfiddle.net/AKXrU/

Note: See TracTickets for help on using tickets.