onmouseover事件触发的疑惑?
http://www.imooc.com/video/2879/0
这节课4分14秒的代码,明明”分享“已经在父盒子div1之外了,将div1绑定onmouseover事件后,为什么鼠标移动到”分享“上仍然可以触发??而类似的下面的这段代码却无法触发alert指令??
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
*{
margin: 0;
padding: 0;
}
.container #share{
width: 20px;
height: 50px;
background: blue;
position: absolute;
left:200px;
top:75px;
}
.container{
width: 200px;
height: 200px;
background: red;
position: relative;
left: -200px;
top: 0px;
}
</style>
<script type="text/javascript">
window.onload=function (){
var container = document.getElementsByClassName('container')
container.onmouseover= function (){
startMove();
}
}
function startMove(){
alert(123);
}
</script>
</head>
<body>
<div class="container">
<span id="share">
分享
</span>
</div>
</body>
</html>