Bind scroll Event To Dynamic DIV?

前端 未结 9 1402
死守一世寂寞
死守一世寂寞 2020-12-11 16:23

For example, after using AJAX, I\'ll have a scrollable DIV. How to bind scroll events to it?

I\'ve tried:

$(window).on(\"scroll\", \".mydiv\", functi         


        
9条回答
  •  隐瞒了意图╮
    2020-12-11 17:12

    try this modified from your code

    http://jsfiddle.net/apDBE/

    $(document).ready(function(){
    
        // Trigger
        $("#btn").click(function(){
            if ($(".myDiv").length == 0) // Append once
            $("body").append('


    Content1



    Content2



    '); }); // Not working $(".myDiv").scroll(function(){ alert("A"); }); // Not working $(document).on("scroll", ".myDiv", function(){ alert("A"); }); });

    Hope this help

提交回复
热议问题