我正在堆叠'THIS'的JavaScript代码

时间:2013-01-28 11:27:25

标签: javascript jquery

我有一个代码,我想在滚动结束时执行。 所以当我滚动“div 1”时,我想用“div2”执行代码。问题是这段代码在代码中有.scrollLoad和一些“this”。如果我用“div2”改变“this”,则代码不起作用。因此,当我滚动到div1时,我希望“this”识别div2。

$( '#div2' ).scrollLoad({


            url : 'load_more_categ.php', //your ajax file to be loaded when scroll breaks ScrollAfterHeight
            type: 'POST',
            data : '',


            start : function() {
                $('<div class="loading"><img src="bigLoader.gif"/></div>').appendTo(this);
            // you can add your effect before loading data
            },

            ScrollAfterHeight : 95,         //this is the height in percentage after which ajax stars

            onload : function( data ) {
                $(this).append( data );

                $('.loading').remove();



            }, // this event fires on ajax success

            continueWhile : function( resp ) {
                if( $(this).children('li').length >= 100 ) { // stops when number of 'li' reaches 100
                    return false;
                }
                return true; 
            }
        });

1 个答案:

答案 0 :(得分:0)

因为在#div2的滚动加载处理程序中声明了javascript,$(this)是#div2。

$( '#div2' ).scrollLoad({