when i’m iterating a collection of inputs, how can I get the current radio index if the input is part of a group of radios?
$('input').each(function(){
if($(this).is(':radio')){
// here get the index of the radio in the radio group,
// like 1, 2, 3 etc...
}
});
The index should be relative to the radio group, no the entire collection of input elements.
The group is determined by the input name (inputs having the same name).
To find the position of the
radiowithin the group defined by theradio‘snameattribute:JS Fiddle proof of concept.
References:
.index().:radioselector.