Radio camera not verified

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 added check = "checked" to the first checkbox, but one of them, for some reason, is the second.

+6
source share
3 answers

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

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

Additional information about the site will be helpful.

+2
source

When there are multiple radio buttons with the same id and / or name attributes, only the last value is used.

Change the name attribute for each switch and it will work.

+1
source

because you use the same name .... id and names must be unique. Replace the name in the second checkbox from radio1 to radio2

-2
source

Source: https://habr.com/ru/post/904978/


All Articles