0

I'm not that great with jQuery but basically, I have a jQuery that displays when scrolling down, new content.

But that new content has div that are under effect of another jQuery function that is called by ready.

So not it only the content that is loaded first when the page loads is working but when the new content is showing is not working on it to.

So I'm thinking maybe I can link the two jQuerys like a trigger when the second jQuery loads to execute the first one, is it possible? How?

Thanks!

UPDATE:

$(document).ready(function($){
        $('.wrapper-hover').hover(
            function () {
                $(this).animate({opacity:'1'});
            },
            function () {
                $(this).animate({opacity:'0'});
            }
        );  
    };
4

3 回答 3

0

尝试使用 Jquery .trigger()来触发一个事件,然后让一些东西监听那个事件

$(document).ready(function($){
    //your event handler
    $('body').on('event', function() {
        $('.wrapper-hover').hover(
            function () {
                $(this).animate({opacity:'1'});
            },
            function () {
                $(this).animate({opacity:'0'});
            }
        );  
    });
};

//when your inifinite scroll finishes trigger the event
$('body').trigger('event');

如果您所做的只是将悬停事件附加到该类,您可能还想考虑事件委托,但仍然不确定您的意图是基于您的问题。

于 2013-07-30T23:55:30.177 回答
0

我解决了callback无限滚动 jquery 的问题。谢谢大家!

于 2013-07-31T12:32:19.587 回答
0

我从您的问题中了解到的是,您希望 div 上的悬停事件在页面加载时效果很好,但在新 div 呈现时不起作用。如果是这样,请尝试以下代码。

$(document).ready(function($){
            $('.wrapper-hover').on("mouseenter", function() {
                $(this).animate({opacity: '0'}, 1000,
                        function() {
                            $(this).animate({opacity: '1'});
                        });
            });
        });
于 2013-07-31T01:37:09.443 回答