带有可点击标签的无线电组 [英] Radio Groups with clickable label

查看:29
本文介绍了带有可点击标签的无线电组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从我收集到的信息来看,为了使单选按钮的标签可点击,您必须为两个元素分配相同的名称"属性值.

From what I have gathered, in order to make a label of a radio button clickable, you must assign the same "name" attribute value to both elements.

我遇到的问题是当您有多个单选按钮时,请说是或否"类型选择.为了使它在单击一个时到达哪个位置,另一个禁用是两个单选按钮的名称"属性必须是相同的值.

The problem I am having is when you have more than one radio button, say a "yes or no" type selection. In order to make it to where if you click one, the other disables is that both radio buttons "name" attribute has to be the same value.

两者都可以吗?

<label for="no">No</label> 
<input type="radio" name="no" value="no" />

<label for="yes">Yes</label> 
<input type="radio" name="yes" value="yes" />

推荐答案

id (not name) 属性应该由标签的 for 属性.应该是这样的:http://jsfiddle.net/zzsSw/

id (not name) attribute should be referred by label's for attribute. It should be like this: http://jsfiddle.net/zzsSw/

<label for="no">No</label> 
<input type="radio" name="mygroup" id="no" value="no" />

<label for="yes">Yes</label> 
<input type="radio" name="mygroup" id="yes" value="yes" />

这篇关于带有可点击标签的无线电组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆