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

前端 未结 3 426
囚心锁ツ
囚心锁ツ 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:37

    I found some solution for this problem.

    $(document).on("mousemove",".objectclass",function(){
       console.log("mousemove");
    });
    

    its works fine!

    0 讨论(0)
  • 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/

    0 讨论(0)
  • 2021-01-06 05:57

    When working with dynamic content be sure to use jquery.on (the newer version of live).

    $.on('click', function(){
    
    });
    

    instead of

    $.click(function(){});
    
    0 讨论(0)
提交回复
热议问题