<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>demo</title> <style type="text/css"> *{ margin: 0; padding: 0; } span{ width: 100px; height: 100px; background: red; text-align: center; line-height: 100px; float: left; } p{ width: 100px; height: 100px; background: blueviolet; text-align: center; line-height: 100px; float: left; display: none; } .dis{ display: block; } </style> </head> <body> <div id="dvd"> <span> 点击 </span> <p>浮动</p> </div> </body> <script> var dvd=document.getElementById('dvd') var s=document.getElementsByTagName('span')[0]; var p=document.getElementsByTagName('p')[0]; dvd.onclick=function(){ console.log('123456789') } s.onmouseover=function(){ p.style.display='block'; } p.onmouseover=function(){ p.style.display='block'; } document.onmouseout=function(){ p.style.display='none'; } </script> </html>
上面是一段很简单的测试代码
如果onmouseover冒泡 就应该触发 onclick 事件 和 onmouseout事件 然而并没有发生
点击onclik事件 也没有触发 onmouseout事件
那么冒泡是怎么一回事 ?
慕田峪6011835
相关分类