JSFiddle - React, Tailwind, and code Playground

by Alessandro Viana

HTML

<div class="quest-alternatives">
<p class="brand-alternative">

<span class="radio-button brand-id" name="123" id="brand-0"></span>
<label for="brand-0" class="brand-name">Opção 0</label></p>

<p class="brand-alternative">

<span class="radio-button brand-id" name="456" id="brand-1"></span>
<label for="brand-1" class="brand-name">Opção 1</label></p>

<p class="brand-alternative">

<span class="radio-button brand-id" name="789" id="brand-2"></span>
<label for="brand-2" class="brand-name">Opção 2</label></p></div>

JavaScript

$('.brand-id').each(function(index, value){
 var id = $(this).attr("id"); // retorna brand-0/brand-1/brand-2
 var valor = $(this).attr("name"); // retorna 123/456/789
 alert(id + "-" + valor);
});