mouseover和mouseenter的区别
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title></title> </head> <body> <input type="checkbox" /> <div style="width: 100px;height: 200px;background-color: #000;display: block;" id="href"> <p>josjofiosj ofsdjfdsjfks</p> <a href="javascript:void(0)" id="" style="width: 100px;height: 100px;background-color: #ff0000;display: block;">1</a> </div> <script> window.onload = function() { var href = document.getElementById('href'); href.addEventListener('mouseover',function() { var i = 0; href.getElementsByTagName("a")[0].text = parseInt(href.getElementsByTagName("a")[0].text) + 1; }) } </script> </body> </html>
mouseover是在指定元素和子元素都会执行,而mouseenter只有在指定元素下执行有作用