Reputation: 4077
I am trying to select all radio buttons with a name, but I can only select the checked ones. For example this works:
$("input[@name='id']:checked").each(function() { // });
It selects all inputs with name id, which are checked (in this case one radio button). But I need all of them, as I need the not checked ones for this name, on this function.
This, for example, is not doing anything:
$("input[@name='id']").each(function() { // });
What do I do?
Thanks!
Upvotes: 7
Views: 16497
Reputation: 2392
Try this
$(':input[type="radio"]').each(function(index){
// YOUR CODE
});
above code will select all input element who's type attribute is radio.
Upvotes: 3
Reputation: 52769
Try -
$("input[name='id']").each(function() {
alert($(this).attr('name'));
});
Upvotes: 1
Reputation: 46647
Try this instead:
$('input[name="yourName"]').each(function () { ... });
Upvotes: 13