marking a radio input as slected when page is loaded
I have two radio buttons. I want one of them to be shown as selected when the page loads. Which property I should use, and how?
Example:
<input type="radio" name="musictype2" value="rock" de开发者_开发知识库fault> Rock<br>
<input type="radio" name="musictype2" value="alternative"> Alternative<br>
<input type="radio" name="test" value="2" checked="checked" />test
like this?
<input type="radio" name="genreselect" value="rock" checked="checked" />
<input type="radio" name="genreselect" value="alternative" />
In this case "rock" is preselected.
<form>
<input type="radio" name="genre" value="rock" checked /> Rock<br />
<input type="radio" name="genre" value="alternative" /> Alternative
</form>
This is the correct way. The name attribute needs to be the same in order for them to switch between.
Check it here.
This is how you use the checked
attribute:
<input type=radio name="my_name" VALUE="my_value" checked />
精彩评论