简体   繁体   中英

jquery fadein div on hover within wordpress loop

I've been playing around with a few different ways of doing this and i'm not 100% sure any of them will work once put into the loop.

I've tried a few different types of jquery hover effects but is there a way to only select the .displayDiv that is a child of the li i'm hovering?

I put where i'm at here: http://jsfiddle.net/XkaLh/

$('li').hover(
    function()
{
    $('.hoverDisplay').animate({ 'opacity': 1 });
},
function()
{
    $('.hoverDisplay').animate({ 'opacity': 0 });
}); 

Thanks in advance for help

You need to limit the lookup hoverDisplay element within the hovered li element

$('li').hover(function () {
    $(this).find('.hoverDisplay').animate({
        'opacity': 1
    });
}, function () {
    $(this).find('.hoverDisplay').animate({
        'opacity': 0
    });
});

Demo: Fiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM