Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#10461 closed bug (worksforme)

selector :checked sometimes returns object with checked attribute false (Opera only)

Reported by: [email protected] Owned by:
Priority: low Milestone: None
Component: selector Version: 1.6.4
Keywords: Cc:
Blocked by: Blocking:


Tested on Opera 11.51 Windows 7. This works at IE 9 and Firefox 6.0.3 and Firefox 7.0.1 without problems. $("input[name='bar']:checked") sometimes returns object with checked attribute set to false.

Clicking on disallow and allow radios sometimes did not change disable property.

How to reproduce bug: clicking on disallow and allow radios with rate 1 click per second. If disabling and enabling checkbox working then click on "Not interesting" radio (unchecked) and then continue clicking on disallow and allow radios.

How to not reproduce bug: click very slow rate (about 1 click per 10 seconds).

I do not know if this selector is invalid (it works in IE and Firefox) but I know how workaround this problem. Instead of $("input[name='bar']:checked") use $("input[name='bar']").filter(":checked")

Example code:

<!DOCTYPE html>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <script type='text/javascript' src='http://code.jquery.com/jquery-1.6.4.js'></script>
  <script type='text/javascript'>
  $(document).ready(function() {
    function update() {
                var element = $("input[name='bar']:checked");   //BUGGY
                //var element = $("input[name='bar']").filter(":checked");//WORKING
                if (element.length==1&&!element[0].checked) {
        var value = element.val();
        if (value == "disallow") {
                disabled: true
        } else {
                disabled: false
    $("input[type='radio']").change(function() {

  <form action="" method="post">
        <input type="radio" name="foo" value="foo1" id="foo1" checked="checked"><label for="foo1">Not interesting 1</label><br> 
        <input type="radio" name="foo" value="foo2" id="foo2"><label for="foo2">Not interesting 2</label><br> 
        <input type="radio" name="bar" value="disallow" id="disallow" checked="checked"><label for="disallow">Disallow checkbox</label><br>
        <input type="radio" name="bar" value="allow" id="allow"><label for="allow">Allow checkbox</label><br> 
        <input type="checkbox" id="some_checkbox" name="some_checkbox"><label for="some_checkbox">some checkbox</label>

Change History (2)

comment:1 Changed 11 years ago by timmywil

Component: unfiledselector
Priority: undecidedlow
Resolution: worksforme
Status: newclosed

Works for me in Opera 11.51.


comment:2 Changed 10 years ago by [email protected]

Hey. I have the same problem. But I found another solution to it! Compare my two versions: http://jsfiddle.net/Lexx918/yzVfc/ (works!) http://jsfiddle.net/Lexx918/yzVfc/1/ (does not work) Different one (well, two) lines.

Note: See TracTickets for help on using tickets.