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
这篇关于你如何使单选按钮文本也可点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:你如何使单选按钮文本也可点击?
基础教程推荐
- 检查 HTML5 拖放文件类型 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
