如何让jquery选择正确的行?

如何让jquery选择正确的行?,jquery,Jquery,Helo朋友们,我需要有关jquery parent>selector的帮助,我无法仅选择鼠标悬停的当前行 <tr> <td> <input type="hidden" id="url" value="http://style"> <div id="link"> <a href="#" id="but"></a> <div id="

Helo朋友们,我需要有关jquery parent>selector的帮助,我无法仅选择鼠标悬停的当前行

<tr>
    <td>
        <input type="hidden" id="url" value="http://style">
        <div id="link">
            <a href="#" id="but"></a>
            <div id="showiframe" style="display: none;">              
                <iframe id="display"></iframe>
            </div>
        </div>
    </td>
</tr>

        $('#link a#but').mouseover(function() {
            $(this).parent("div").find('#showiframe').show();
            $(this).parent("div").find("#display").attr('src', $('#url').val());
        });
        $('#showiframe').mouseout(function() {
            $(this).hide();
        });

$(“#链接a#but”).mouseover(函数(){
$(this.parent(“div”).find(“#showiframe”).show();
$(this.parent(“div”).find(#display”).attr('src',$('#url').val());
});
$('#showiframe').mouseout(函数(){
$(this.hide();
});
那么,如何分别为每一行执行此操作?每一行在#url中都有不同的值

而且它必须在鼠标上方工作


请帮忙!谢谢

如果在选择器中使用ID 它们必须动态生成,但您可以将代码更改为

$(document).ready ( function () {
    $('div a').hover(function () {
        var p = $(this).parent("div");
        var url = p.siblings('input').val();
        p.find('div').show();
        p.find('iframe').attr('src', url);
    }, function () {
        $(this).siblings('div').hide();
    });
});

您不应该使用ID,而应该使用类。我很高兴它有帮助。