mouseenter event called twice even after stopPropagation

后端 未结 4 837
南笙
南笙 2021-01-22 18:19

I\'m new to jquery and am facing now a weird problem. I succeeded to narrow it down to the fact that a mouseenter event is called twice: once for the containing div (this was my

4条回答
  •  情歌与酒
    2021-01-22 18:48

    i think that the second one does'nt work because the html is different. If you use the same html you don't need stopPropagation or return false at all. Look at the fiddle: http://jsfiddle.net/aC3TG/1/

    $(function (){
        $(".testDiv").hover(
        function(e) /* IN */ {
            $(this).data("htmlBackup", $(this).html());
            $(this).html("TEST 123");
        }, function(e) /* OUT */ {
            $(this).html($(this).data("htmlBackup"));
    
        });
    });         
    

提交回复
热议问题