且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

隐藏包含特定字符串的div

更新时间:2023-02-26 11:16:13

感谢帮助人员!事实证明该脚本正在运行,但是由于页面在滚动时会自动加载新的div,因此必须在页面加载后运行脚本.

Thanks for the help guys! Turns out that the script was working however as the page loaded new divs automatically when scrolling, the script had to be run after the page loaded them.

最终脚本看起来像

$(window).load(function(){  
    $(".photos-wrapper:contains('zynthesized')").hide();  
});  

$(window).on('scroll', function() {
    var y_scroll_pos = window.pageYOffset;
    var scroll_pos_test = 150;             

    if(y_scroll_pos > scroll_pos_test) {
        $(".photos-wrapper:contains('zynthesized')").hide();
    }
});

希望这对希望做类似事情的人有所帮助!

Hopefully this helps anyone looking to do something similar!