单击图像并选择无线电不工作

Sat*_*000 4 html xhtml

我有这个代码,当我点击它的图像时无法选择收音机.

我错过了什么?

这是当前的代码:

<label style="display: inline; " for="test1">

<img src="images/image1.jpg" />

<input checked="checked" class="select_control" id="select1" name="test1" type="radio" value="value1" />
</label>

<label style="display: inline; " for="test2">

<img src="images/image2.jpg" />

<input checked="checked" class="select_control" id="select2" name="test2" type="radio" value="value2" />
</label>
Run Code Online (Sandbox Code Playgroud)

Mis*_*lin 16

for标签中的属性应与输入匹配,id而不是匹配name.name用于对单选按钮和复选框进行分组(当它们在一个组中时,它们的名称相同,因此选中一个将取消选中另一个).

<label for="test1">
  <img src="image1.jpg" />
  <input id="test1" name="test" type="radio" value="value1" />
</label>
<label for="test2">
    <img src="image2.jpg" />
    <input id="test2" name="test" type="radio" value="value2" />
</label>
Run Code Online (Sandbox Code Playgroud)

以下是您的代码的工作示例:http://jsfiddle.net/nXb5a/