Php 当用户将鼠标悬停在JQuery中单选按钮的标签上时显示工具提示

Php 当用户将鼠标悬停在JQuery中单选按钮的标签上时显示工具提示,php,jquery,zend-form,Php,Jquery,Zend 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="

我在表单中有一些单选按钮:

<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>

资料
测试1

测试2
测试数据
二次试验数据
未分配

当用户将鼠标悬停在单选按钮的标签上时,我试图显示工具提示。我可以这样做,但我也想得到单选按钮“value”属性中的任何内容。我尝试这样做的结果是,无论哪个单选按钮悬停在哪个单选按钮上,都只返回单选按钮的“值”


感谢您的帮助。

如果我理解正确,当您将鼠标悬停在
标签上时,您希望获得与
标签相关联的单选按钮的值。如果是这种情况,请尝试以下操作:

$("label").mouseover(function() {
    var radioButtonValue = $(this).find("input").val(); 
});

这是一个。

您可以显示当前用于尝试检索值的代码吗?是的,这就是我想要的。我看了这个示例,但控制台上没有任何记录…@Sid-在哪个示例中?我的答案中的链接肯定会将这些值记录到我的控制台!在HerrSerker在评论中发布的链接中,该值用作
title
属性。在这两个示例中,我单击链接,然后将鼠标悬停在标签上,并使用firebug检查控制台,但没有任何内容。显然,我的设置或检查方式有问题。此代码使用该值查找该无线电复选框。这意味着它不依赖于html的结构,只是您的“for”属性值是准确的。感谢这项工作,但您能否解释从“function(event){..”开始的代码?请注意更多的注意事项,您不能摇动棍子;)
//this is just one way to register to the window.onLoad event in jQuery, i prefer it's readability for what is going on    
$(document).ready(function(){
//$("something", "something else") - 'Something Else' limits where jQuery searches for 'something'
// .hover( function A , function B ) - function A is the mouseover event, function B is the mouseleave event
// function(event){}  for All events, jQuery will always pass an "event" parameter if you ask for it on the window .event() registration.  cool stuff you can do with jQuery's "event" parameter can be found here in the references below.
      $("label", "#data_id-element").hover(function(event){
// $(this)  jQuery'itize the html Element the user hovered into 
// .attr("for") - get the value of the 'for' attribute
// $("#" + whatever) - get whatever this is by its id='' attribute
// .val()  - get the value of whatever this is
         var radioValue = $("#"+$(this).attr("for")).val();
      }, 
      function(event){
// $(this)  jQuery'itize the html Element the user hovered out of
// .attr("for") - get the value of the 'for' attribute
// $("#" + whatever) - get whatever this is by its id='' attribute
// .val()  - get the value of whatever this is
        var radioValue = $("#"+$(this).attr("for")).val();
      });

    });