[英]How to show a hidden div on mouse over on a series of images
我有一系列隱藏了div描述的圖像。 我正在嘗試顯示懸停事件的描述。 我看不到它能正常工作。 這是代碼。
<div class="peopleImage" id="image1">
<img src="image1.jpg">
<div class="peopleInfo">Description goes here</div>
</div>
<div class="peopleImage" id="image1">
<img src="image1.jpg">
<div class="peopleInfo">Description goes here</div>
</div>
<div class="peopleImage" id="image1">
<img src="image1.jpg">
<div class="peopleInfo">Description goes here</div>
</div>
這是我正在使用的jQuery:
$(".peopleImage").hover(function () {
var peopleInfo = $(this).closest('.peopleInfo');
peopleInfo.show();
});
似乎什么都沒發生。 任何建議,將不勝感激!
嘗試這個:
$(".peopleImage").hover(function () {
$('.peopleInfo', this).show();
}, function() {
$('.peopleInfo', this).hide();
});
嘗試
(".peopleInfo").show()
為每個div分配單獨的ID,並嘗試使用該ID調用show()。
那會更好
最近的是獲得祖先,您需要找到孩子-看看這個帖子:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.