当用户将鼠标悬停在 JQuery 中单选按钮的标签上时显示工具提示
我的表单中有一些单选按钮:
<div id="data_id-block">
<dt id="data_id-label"><label class="required">Data</label></dt>
<dd id="data_id-element">
<label for="data_id-1">
<input type="radio" name="data_id" id="data_id-1" value="1" />test 1
</label><br />
<label for="data_id-2">
<input type="radio" name="data_id" id="data_id-2" value="2" />test 2
</label><br />
<label for="data_id-4">
<input type="radio" name="data_id" id="data_id-4" value="4" /> Test Data
</label><br />
<label for="data_id-5">
<input type="radio" name="data_id" id="data_id-5" value="5" /> Second Test Data
</label><br />
<label for="data_id-6">
<input type="radio" name="data_id" id="data_id-6" value="6" />Unassigned
</label>
</dd>
我试图在用户将鼠标悬停在单选按钮的标签上时显示工具提示。我可以做到这一点,但我也想获取单选按钮的“value”属性中的任何内容。我的尝试导致仅返回单选按钮的“值”,无论将鼠标悬停在哪个单选按钮上。
感谢您的帮助。
I have some radio buttons in a form:
<div id="data_id-block">
<dt id="data_id-label"><label class="required">Data</label></dt>
<dd id="data_id-element">
<label for="data_id-1">
<input type="radio" name="data_id" id="data_id-1" value="1" />test 1
</label><br />
<label for="data_id-2">
<input type="radio" name="data_id" id="data_id-2" value="2" />test 2
</label><br />
<label for="data_id-4">
<input type="radio" name="data_id" id="data_id-4" value="4" /> Test Data
</label><br />
<label for="data_id-5">
<input type="radio" name="data_id" id="data_id-5" value="5" /> Second Test Data
</label><br />
<label for="data_id-6">
<input type="radio" name="data_id" id="data_id-6" value="6" />Unassigned
</label>
</dd>
I'm trying to display a tooltip when a user hovers over the label of the radio button. I can do this but I also want to get whatever is in the 'value' property of the radio button. My attempts to this resulted in only the 'value' of the radio button being returned regardless of which radio button was hovered over.
Appreciate the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我理解正确的话,当您将鼠标悬停在
label
上时,您希望获取与label
关联的单选按钮的值。如果是这种情况,请尝试如下操作:这是一个工作示例。
If I've understood you correctly, you want to get the value of the radio button associated with a
label
, when you hover over thelabel
. If that's the case, try something like this:Here's a working example.