简体   繁体   English

我与“ THIS” JavaScript代码堆叠在一起

[英]I am stack with 'THIS' javascript code

I have a code that i want to execute when scroll end. 我有一个要在滚动结束时执行的代码。 So when i scroll "div 1" i want to execute the code with "div2". 因此,当我滚动“ div 1”时,我想使用“ div2”执行代码。 The problem is that this code have .scrollLoad and some "this" in the code. 问题在于此代码中包含.scrollLoad和一些“ this”。 If i change "this" with "div2" the code don't work. 如果我将“ this”更改为“ div2”,则代码无效。 So when i scroll to div1 I want "this" to recognize the div2. 因此,当我滚动到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; 
            }
        });

因为javascript在#div2的scrollload处理程序中被删除,所以$(this)是#div2。

$( '#div2' ).scrollLoad({

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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