Home > Web Front-end > HTML Tutorial > Determine whether the radio in the input box in html is selected

Determine whether the radio in the input box in html is selected

黄舟
Release: 2017-07-27 14:23:12
Original
2907 people have browsed it

Write less words and speak directly in code:

<html>

<body>


男性:<input type="radio" id="male" name="xxx"/>
<br />
女性:<input type="radio" id="female" name="xxx"/>
<br />

<button onClick="output()">test</button>

<script>
function output()
{
    if(document.getElementById("male").checked)
	{
		alert("1");
	}

    if(document.getElementById("female").checked)
	{
		alert("2");
	}
}
</script>

</body>
</html>
Copy after login

Done.

The above is the detailed content of Determine whether the radio in the input box in html is selected. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template