JSFiddle - React, Tailwind, and code Playground
by Joulence
HTML
<div>
<label><input type="radio" name="trade" id="long" checked> Long</label>
<label><input type="radio" name="trade" id="short"> Short</label>
</div>
<hr/>
<input type="button" value="check" onclick="check()" />
<br/>
<input type="button" value="check jQuery" onclick="check2()" />
JavaScript
function check()
{
var inp = document.getElementsByName('trade');
for (var i = 0; i < inp.length; i++) {
if (inp[i].type == "radio" && inp[i].checked) {
alert("selected: " + inp[i].value);
}
}
}
function check2()
{
alert("selected: " + $('input[name=r]:checked').val());
}