Answer the question
In order to leave comments, you need to log in
Why don't you explain it?
What's wrong with the
HTML code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<input type="radio" name="r1" value="5">0
<input type="radio" name="r1" value="53">1
<input type="radio" name="r1" value="535">2
<button onclick="fun1()">Проверить какой из элементов выбран</button>
<script src="script.js"></script>
</body>
</html>
function fun1() {
var radi = document.getElementsByName('r1');
for (var i = 0; i < radi.length; i++); {
if (radi[i].checked) {
alert('Выбран' + i + 'элемент');
}
}
}
Answer the question
In order to leave comments, you need to log in
document.querySelector("input[name=r1]:checked")
Of course, I will not correct errors and show them too.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question