Skip to main content

Bug Tracker

Side navigation

#6028 closed bug (worksforme)

Opened February 04, 2010 04:40PM UTC

Closed February 04, 2010 05:01PM UTC

Last modified February 04, 2010 05:09PM UTC

JQuery doesn't work with multiple attribute selector on IE 8, FireFox and Chrome

Reported by: indomitable Owned by:
Priority: major Milestone:
Component: selector Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:
Description

JQuery fails (IE8, FireFox and Chrome, but works fine on IE8 compatibility mode) in following example:

ASP.NET and GridView with id gvRadioButtons, I wan't to create a radio buttons column and I use ItemTemplate with radio button, but every radio button is rendered with different name attribute (may be a bug in asp.net no matter this isn't related to problem), that's why I wrote a custom onclick function:

function OnClickRadio(rb) {

$("#gvRadioButtons input[type='radio']").each(function(inx, obj) {

obj.checked = "";

});

rb.checked = 'checked';

}

Ok for now, I always have only one checked radio button

The problem is when I want to find checked radio button.

First I use (and this works on compatibility mode of IE8)

$("#gvRadioButtons input[type='radio'][checked]")

but it fails on Firefox/Chrome.

I have to write a function that seeks checked radios

function HasChecked(radioButtons) {

for (i = 0; i < radioButtons.length; i++) {

if (radioButtons[i].checked) {

return true;

}

}

return false;

}

var checkedRadios = $("#gvRadioButtons input[type='radio']");

if (! HasChecked(checkedRadios)) {

//Do Something

}

Finally the problem is that $("input[type='radio'][checked]") doesn't work :(

Attachments (1)
  • index.html (1.4 KB) - added by indomitable February 04, 2010 05:06PM UTC.

    Here it is a simple example

Change History (2)

Changed February 04, 2010 05:01PM UTC by john comment:1

component: unfilledselector
resolution: → worksforme
status: newclosed

Why not just use :checked? That's provided for this exact purpose.

Changed February 04, 2010 05:09PM UTC by indomitable comment:2

I can't use just checked because If I have other kinds of inputs like type="checkbox" it won't work as I want.