你如何使单选按钮文字也可点击? [英] How do you make the radio button text to be clickable too?

查看:75
本文介绍了你如何使单选按钮文字也可点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个单选按钮(以及其他一些):

i have this radio button (and some other after this one):

<input type="radio" name="group1" value="Milk"> Milk<br>

但是如果我想激活单选按钮,我必须单击它,单击牛奶在按钮的右侧,不会激活它。我怎么做到这一点?,我发现的关于单选按钮的所有例子都有同样的问题。提前感谢。

But if i want to activate the radio button, i have to click it, clicking the word "Milk" which is to the right of the button, doesn't activate it. How can i do that?, all the examples i found about radio buttons so far, have the same issue. Thanks in advance.

推荐答案

在这里您要使用标签标签。

Here you want to use the label tag.

类似于:

Something like:

            <label>
                <input type="radio" name="group1" value="Milk">
                Milk
            </label><br/>

标签告诉浏览器包含在内的所有内容都应该被视为一个元素(根据文本)。不是div)

Labels tell the browser that everything contained within should be treated as one element (in terms of text. They are not divs)

看一下这个例子: http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_label

这篇关于你如何使单选按钮文字也可点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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