Hello, I have the following code below where I wanted to control the radios. I want to have an "event" triggered when the each one ends scanning the entire group of radios 1 whose name is "group1". That is, at the end of each group of radios swept a message or a variable is changed its status. ex: When arriving at group1 with value 4 a message is sent. When arriving at the last element of group2 must also be triggered "event". This has to be DYNAMIC. For any other or amount of radios elements.
$(function() {
$("#botao").click(function() {
$("textarea[name='arraytextArea[]'],input[name='grupo1'],input[name='grupo2']").each(function(i, el) {
alert("Valor:" + $(el).val());
});
})
});
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script></head><body><div><textareaname='arraytextArea[]'></textarea><br><inputtype="radio" name="grupo1" value="Valor1"><span>Valor1</span>
<input type="radio" name="grupo1" value="Valor2"><span>Valor2</span>
<input type="radio" name="grupo1" value="Valor3"><span>Valor3</span>
<input type="radio" name="grupo1" value="Valor4"><span>Valor4</span>
<br><textarea name='arraytextArea[]'></textarea> <br>
<input type="radio" name="grupo2" value="Valor1"><span>Valor2</span>
<input type="radio" name="grupo2" value="Valor2"><span>Valor3</span>
<input type="radio" name="grupo2" value="Valor3"><span>Valor4</span>
<input type="radio" name="grupo2" value="Valor4"><span>Valor5</span><br>
<input type="button" value="Enviar" id="botao">
</div>
</body>
</html>