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!
Try this
$(':input[type="radio"]').each(function(index){
// YOUR CODE
});
above code will select all input element who's type attribute is radio .
Try -
$("input[name='id']").each(function() {
alert($(this).attr('name'));
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.