Helo朋友,我需要帮助jquery parent>选择器,我不能让它只选择鼠标结束的当前行。
<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();
});
那么,如何分别为每一行做这个工作?每行在#url中都有不同的值。
并且它必须在鼠标悬停上工作......
请帮忙!谢谢!
答案 0 :(得分:0)
如果您在选择器中使用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();
});
});