Bind scroll Event To Dynamic DIV?

前端 未结 9 1427
死守一世寂寞
死守一世寂寞 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 16:52

    http://jsfiddle.net/hainawa/cruut/

    $(document).ready(function(){
        var $mydiv = $('


    Content1



    Content2



    '); // It will work $mydiv.scroll(function(){ alert("A"); }); // Trigger $("#btn").click(function(){ //You are using the method append,so you don't need judge if div.mydiv exits. //You'll need do this if you're using display:none $("body").append($mydiv); }); });

提交回复
热议问题