Is it possible to use jQuery .on and hover?

前端 未结 10 889
失恋的感觉
失恋的感觉 2020-11-22 11:03

I have a

    that is populated with javascript after the initial page load. I\'m currently using .bind with mouseover and
10条回答
  •  故里飘歌
    2020-11-22 11:26

    None of these solutions worked for me when mousing over/out of objects created after the document has loaded as the question requests. I know this question is old but I have a solution for those still looking:

    $("#container").on('mouseenter', '.selector', function() {
        //do something
    });
    $("#container").on('mouseleave', '.selector', function() {
        //do something
    });
    

    This will bind the functions to the selector so that objects with this selector made after the document is ready will still be able to call it.

提交回复
热议问题