Bug Tracker

Modify

Ticket #6028 (closed bug: worksforme)

Opened 3 years ago

Last modified 3 years ago

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

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

index.html Download (1.4 KB) - added by indomitable 3 years ago.
Here it is a simple example

Change History

comment:1 Changed 3 years ago by john

  • Status changed from new to closed
  • Resolution set to worksforme
  • Component changed from unfilled to selector

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

Changed 3 years ago by indomitable

Here it is a simple example

comment:2 Changed 3 years ago by indomitable

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

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.