Pycharm上未解析的每个函数

问题描述 投票:-1回答:1

我想使用jquery函数,但是我无法解析.each()函数。我有JQuery-3.4.1.js文件,所以我不确定我需要另一个文件吗?

$(function(){
  $(window).scroll( function(){

        /* Check the location of each desired element */
        $('.hideme').each( function(i){

            var bottom_of_object = $(this).offset().top + $(this).outerHeight();
            var bottom_of_window = $(window).scrollTop() + $(window).height();

            /* If the object is completely visible in the window, fade it it */
            if( bottom_of_window > bottom_of_object ){

                $(this).animate({'opacity':'1'},500);

            }

        });

    });
});

甚至在3.4.1上也无法识别吗?我对此并不陌生,所以可能会遗漏一些明显的东西...

javascript jquery pycharm
1个回答
0
投票

function(i)each参数中查找e

        //Im adding i,e (i => index, e => theElement) // NOT $(this)
        $('.hideme').each( function(i,e){

            var bottom_of_object = $(this).offset().top + $(this).outerHeight();
            var bottom_of_window = $(window).scrollTop() + $(window).height();

            if( bottom_of_window > bottom_of_object ){

                //Im changing $(this) to $(e)
                $(e).animate({'opacity':'1'},500);

            }

        });
© www.soinside.com 2019 - 2024. All rights reserved.