Jquery - Hover effect not working when loading dynamic content - URI with hastags

前端 未结 3 429
囚心锁ツ
囚心锁ツ 2021-01-06 05:21

I am currently working the front-end on a website. I am using jquery in order to create a dynamic content.

My problem is that when I type my URI (localhost/jquery/my

3条回答
  •  渐次进展
    2021-01-06 05:52

    Try using on() if you are using a recent version of jQuery (1.7+), or delegate() if its an older version, instead of just hover()

    Like this:

    $("#main-content").on("mouseenter", "#items .item", function(event){
    // your function
    }).on("mouseleave", "#items .item", function(event){
    // your function
    });
    

    See: http://api.jquery.com/on/

提交回复
热议问题