JQuery: How to select all radio buttons with a name?

I try to select all the switches with the name, but I can only select the checked ones. For example, this works:

$("input[@name='id']:checked").each(function() { // }); 

It selects all inputs with a name identifier that are checked (in this case, one switch). But I need all of them, because I need not verified for this name, for this function.

This, for example, does nothing:

 $("input[@name='id']").each(function() { // }); 

What should I do?

Thanks!

+4
source share
3 answers

Try this instead:

 $('input[name="yourName"]').each(function () { ... }); 

http://jsfiddle.net/sFtdR/

+10
source

try it

 $(':input[type="radio"]').each(function(index){ // YOUR CODE }); 

Above, the code will select all input elements whose type is radio .

+2
source

Try it -

 $("input[name='id']").each(function() { alert($(this).attr('name')); }); 
+1
source

All Articles