Bug Tracker

Modify

Ticket #8731 (closed bug: worksforme)

Opened 2 years ago

Last modified 2 years ago

: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:
Blocking: Blocked by:

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

comment:1 Changed 2 years ago by addyosmani

  • Priority changed from undecided to low
  • Status changed from new to closed
  • Resolution set to worksforme

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/

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.