带可点击标签的广播组 [英] Radio Groups with clickable label

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

问题描述

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

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.

我遇到的问题是当您有多个单选按钮时,说是或否类型选择。为了使它到达如果你点击一个,其他禁用是单选按钮name属性必须是相同的值。

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.

是否有可能两个都做?

Is it possible to do both?

<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天全站免登陆