There are several input radio , but only one checked , that's what you need to access it using Javascript.
In general, an analogue of the Jquery function is needed:
$(".item:radio:checked").click(); There are several input radio , but only one checked , that's what you need to access it using Javascript.
In general, an analogue of the Jquery function is needed:
$(".item:radio:checked").click(); There is such a thing as Document.querySelector () - returns the first element inside the document (using a pre-ordered depth traversal of nodes to the first found node) that matches a certain group of selectors.
Syntax
element = document.querySelector(selectors); Where
element is an element object.selectors - a string containing one or more CSS selectors, separated by a comma
var checkedRadio = document.querySelector('input[name="rate"]:checked'); console.log(checkedRadio); console.log(checkedRadio.value); <div id="rates"> <input type="radio" id="r1" name="rate" value="Fixed Rate"> Fixed Rate <input type="radio" id="r2" name="rate" value="Variable Rate"> Variable Rate <input type="radio" id="r3" name="rate" value="Multi Rate" checked="checked"> Multi Rate </div> another option
var radios = document.getElementsByName('genderS'); for (var i = 0, length = radios.length; i < length; i++) { if (radios[i].checked) { console.log(radios[i].value); break; } } <input type="radio" name="genderS" value="male" checked>Male <input type="radio" name="genderS" value="female">Female Source: https://ru.stackoverflow.com/questions/598817/
All Articles
$("radio:checked").click();not satisfied? - Andrew B