所以我有一个脚本可以将获取的数据加载到锚点中的范围内。
链接:
<a id="dbobject" tdbid="1">Weapon of mass destruction<span>fetch content goes here</span></a>
Jquery:
$(document).ready(function(){
$('a[tdbid]').each(function(){
$(this).load('data/fetch.php?id='+ $(this).attr('tdbid'), function(){
});
});
});
内容完全加载到跨度中。当您悬停链接时,它会显示带有内容的跨度。但我宁愿在链接之外设置跨度,所以当你离开锚点时窗口会消失,
现在当你将鼠标悬停在它上面时,如果该链接下面有更多链接,你也可以将鼠标放在跨度内,这对于用户来说真的不方便。
我尝试过:
链接:
<a id="dbobject" tdbid="1">Weapon of mass destruction</a><span>fetch content goes here</span>
Jquery:
$(document).ready(function(){
$('a[tdbid]').each(function(){
$(this).closest('span').load('data/fetch.php?id='+ $(this).attr('tdbid'), function(){
});
});
});
哪个不起作用。但是在我想到的时候,如果我想在悬停时显示该范围,那么我必须将范围默认设置为隐藏。因此,没有链接的整个页面的跨度也将被隐藏,这不是我打算做的。
那么如何让我的悬停显示内部获取内容的div?
答案 0 :(得分:0)
对于使用<span>
之后的<a>
:
$(document).ready(function(){
$('a[tdbid] + span').each(function(){
$(this).load('data/fetch.php?id='+ $(this).attr('tdbid'), function(){
});
});
});
“nearest”返回最近的祖先。你需要的是下一个兄弟。