Jquery – double click function by JQuery doesn’t work on radio input in FireFox

firefoxjquery

I wrote below code to remove checked item from radio group in my form by double click.

$("input[type='radio']").each(function(){
            $(this).dblclick(function(){
                $(this).removeAttr("checked");
            });
        });

but this code doesn't work in FireFox but work in IE.
anybody know what's the problem?

tanx

Best Answer

Either way, you probably want to wire it up a little differently.

$("input[type='radio']").dblclick(function(){
  $(this).removeAttr("checked");
});

One thing that can help when learning jQuery is to think set-based, like SQL. Selectors can select one or a group of elements. Any function or event you call on the group applies to the whole group.