jQuery .delegate() not working on load and changeData events

后端 未结 3 1658
轻奢々
轻奢々 2021-01-13 05:39

Can someone enlighten me on the jQuery delegate, what events are handled and what aren\'t. The follow code doesn\'t work

$(\"#browser\").delegate( \".photo\"         


        
3条回答
  •  野的像风
    2021-01-13 06:10

    For newer versions of jQuery, where the .on() method is favored before the .delegate() or .live() methods, it won't work in this way, too

    // wrong
    jQuery(selector).on('load', 'img', myFunc)
    

    because the load event does not bubble

    make it like this

    jQuery(selector).find('img').on('load', myFunc)
    

提交回复
热议问题