你如何使单选按钮文本也可点击?

How do you make the radio button text to be clickable too?(你如何使单选按钮文本也可点击?)
本文介绍了你如何使单选按钮文本也可点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

推荐答案

这里要使用label标签.

Here you want to use the label tag.

类似:

            <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

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

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

how to remove this error quot;Response must contain an array at quot; . quot;.quot; while making dropdown(如何删除此错误quot;响应必须在quot;处包含数组。创建下拉菜单时(Q;))
Why is it necessary to use `document.createElementNS` when adding `svg` tags to an HTML document via JS?(为什么在通过JS为一个HTML文档添加`svg`标签时,需要使用`Document.createElementNS`?)
wkhtmltopdf print-media-type uses @media print ONLY and ignores the rest(Wkhtmltopdf print-media-type仅使用@media print,而忽略其余内容)
price depend on selection of radio input(价格取决于无线电输入的选择)
calculate price depend on selection without button(根据没有按钮的选择计算价格)
What should I consider before minifying HTML?(在缩小HTML之前,我应该考虑什么?)