jquery specific show buttons on hover(悬停时特定于 jquery 的显示按钮)
问题描述
我有一个应用程序通过循环创建一堆 div.
I have an application creating a bunch of divs through a loop.
每个 div 都有产品"类
Each div has the class "product"
看起来像
<div class="product">
!.....stuff here ....!
<div class="show_on_hover">...buttons here... </div>
</div>
所以每页大约有 12 个相同的 div.
so there are about 12 of these same divs per page.
我想将鼠标悬停在一个特定的上方并显示最初设置为 display:none 的特定show_on_hover"div.
I would like to hover over a specific one and show the specific "show_on_hover" div which is initially set to display:none.
$('.product').hover(function() {
$(.show_on_hover).show();
},
function () {
$(.show_on_hover).hide();
}
);
到目前为止,这就是我所拥有的,但它会在页面上显示所有 .show_on_hovers,所以我想知道如何仅获取您将鼠标悬停在上面的特定显示.当您将鼠标悬停在任何评论上时,会在 youtube 上看到这种效果,并且会弹出一些评论工具.
That is what I have so far but it will show ALL of the .show_on_hovers on the page so I am wondering how to get only the specific one you have moused over to show. This effect is seen on youtube when you mouseover any of the comments, and some comment tools pop up.
谢谢!
推荐答案
find 将在悬停的 .product
中找到您的 .show_on_hover
div.试试这个:
find will find your .show_on_hover
divs inside the hovered .product
. Try this:
$('.product').hover(function() {
$(this).find('.show_on_hover').show();
},
function () {
$(this).find('.show_on_hover').hide();
}
);
这篇关于悬停时特定于 jquery 的显示按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:悬停时特定于 jquery 的显示按钮


- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01