简单的jquery代码仅在悬停LI时显示段落
<ol id="sortme">
<li>this content <p class="edit">first hidden content</p></li>
<li>this content <p class="edit">second hidden content</p></li>
<li>this content <p class="edit">third hidden content</p></li>
</ol>
Jquery
$(".edit").hide;
$('#sortme li').hover(
function () {
$(".edit").show();
},
function () {
$(".edit").hide();
}
);
我的问题是当将鼠标悬停在所有段落的任何一个上时 我需要一对一地做 因此,当鼠标悬停在第一个 li 时,会出现“第一个隐藏内容” 当鼠标悬停在第二个里时,“第一个隐藏内容”消失,“第二个隐藏内容”消失
列表的其余部分依此类推
最佳答案
您可以通过将其作为第二个参数提供给 $()
来在 this
上下文中进行搜索:
$(".edit").hide;
$('#sortme li').hover(
function () {
$(".edit", this).show();
},
function () {
$(".edit", this).hide();
}
);
关于javascript - jquery悬停li以显示段落内?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12653388/