简体   繁体   中英

What is controlling the radio buttons in HTML5

Take this code for Example

<form>
<input type="radio" name="sex" value="male" checked>Male
<br>
<input type="radio" name="sex" value="female">Female
</form>

It allows a user to select one button at a time, I was always under the impression that javascript was the answer to this type of a solution. So my question is, is there any embedded javascript in the HTML radio button and if not, where is the function coming from?

Its the Browser's duty to do that for us.

Why?

Because the behavior is stated in the spec:

http://www.w3.org/TR/html/forms.html#radio-button-state-(type=radio)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM