Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Radio Button Checked not checking

Tags:

html

forms

xhtml

I am having a problem with the following code:

<div>
<span>Item 1</span>
<input type="radio" name="radio1" id="radio1" checked="checked" />
</div>

<div>
<span>Item 2</span>
<input type="radio" name="radio1" class="checkbox" id="radio2" />
</div>

I have added checked="checked" to the first checkbox but the one checked is the second one for some reason.

like image 511
Satch3000 Avatar asked Jan 03 '12 11:01

Satch3000


1 Answers

Judging by the code you posted, something in the missing code must be wronge. I put your code in a jsfiddle (1) and it works like a charm.

According to w3schools, checked="checked" is correct (http://www.w3schools.com/TAGS/att_input_checked.asp). I often use <input type="radio" "name="foo" checked />, which also works.

More infos about the site would be helpful.

like image 77
Phil Avatar answered Nov 15 '22 09:11

Phil