Opened 13 years ago
Closed 12 years ago
#6133 closed bug (fixed)
:checked fails on dynamically generated checkboxes in Opera 10
Reported by: | yurgon | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | 1.next |
Component: | selector | Version: | 1.4.1 |
Keywords: | checked opera10 | Cc: | |
Blocked by: | Blocking: |
Description
In Opera 10.10, the :checked selector fails on checkboxes that are dynamically generated into the DOM by AJAX requests, document.write(), $.append() etc. The problem appears on checkboxes but not on radiobuttons. Other browsers work fine (tested in IE 6-8, Firefox 3.6, Chrome 4.0, Safari 4.0). Unfortunately, I don't have older versions of Opera available for testing. The same problem existed in jQuery 1.3.2.
The attached HTML file demonstrates the problem: the total number of :checked elements is counted. The link "Duplicate <div> with checkboxes and radiobuttons" clones the form and inserts the clone into the DOM. In Opera 10, the updated count of :checked elements is now wrong - the new checkboxes are ignored. Manually un- and then rechecking the checkboxes sets the count right.
The problem appears to be independent of the technique used to insert content into the DOM (I originally noticed it on content delivered by AJAX request).
Attachments (1)
Change History (8)
Changed 13 years ago by
Attachment: | jquery_bug_checked_opera.html added |
---|
comment:1 Changed 12 years ago by
Milestone: | 1.4.2 → 1.4.4 |
---|---|
Priority: | → undecided |
Status: | new → open |
comment:2 Changed 12 years ago by
Confirmed in Opera 9.64, 10.10, 10.20, 10.50, 10.63, and 11 alpha.
Updated test case to use 1.4.3: http://miketaylr.com/test/jquery_bug_checked_opera.htm
comment:3 Changed 12 years ago by
Milestone: | 1.4.4 → 1.5 |
---|---|
Priority: | undecided → low |
comment:4 follow-up: 5 Changed 12 years ago by
Workaround: You can use .attr("checked") to find out if the checkboxes are currently checked. I added a class to my generated checkboxes to easily select them and then used a foreach loop to evaluate the checked attribute.
Example: $("input.checkboxClass").each(function() { alert($(this).attr("checked")); });
comment:5 Changed 12 years ago by
Replying to anonymous:
Workaround: You can use .attr("checked") to find out if the checkboxes are currently checked.
Confirmed, that workaround works. It's still a workaround, though. :-)
BTW, I just confirmed the Bug in Opera 11.01 (Build 1190, Win32) with the test case provided by miketaylr for jQuery 1.4.3.
comment:6 Changed 12 years ago by
:checkbox:checked also works as a workaround
eg.
$('.myClass:checked').length = 0 $('.myClass:checkbox:checked').length = 4
comment:7 Changed 12 years ago by
Milestone: | → 1.next |
---|---|
Resolution: | → fixed |
Status: | open → closed |
http://jsfiddle.net/danheberden/VEtms/ - works on opera 11 and 10 with jq 1.5.1
HTML demo for #6133