其他分享
首页 > 其他分享> > mouseover和mouseenter的区别

mouseover和mouseenter的区别

作者:互联网

   <script>
        var father = document.querySelector('.father')
        // mouseover事件,鼠标经过father会触发,鼠标经过子盒子son还会触发。会冒泡。
        father.addEventListener('mouseover', function(){
            console.log('1');
        })
        // mouseenter事件,不会冒泡,经过子盒子不会触发。
        father.addEventListener('mouseenter', function(){
            console.log('2');
        })
        // mouseleave事件,离开时触发,不会冒泡
        father.addEventListener('mouseleave', function(){
            console.log('3');
        })
    </script>

标签:function,log,区别,father,冒泡,addEventListener,mouseover,mouseenter
来源: https://www.cnblogs.com/--wx/p/15375820.html