悬停时特定于 jquery 的显示按钮 [英] jquery specific show buttons on hover

查看:10
本文介绍了悬停时特定于 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 的显示按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆