初学菜鸟,找不出问题,求大神告知为何没有效果
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>水导航</title>
<style type="text/css">
*{
padding: 0;
margin: 0;
}
ul{
list-style: none;
height: 50px;
border-bottom: 2px solid lightblue;
}
ul li{
float: left;
width: 120px;
margin:0 1px;
position: relative;
left: 20px;
}
a{
text-decoration: none;
display: inline-block;
width: 100%;
height: 50px;
line-height: 50px;
background: bisque;
text-align: center;
border-top-left-radius: 20px;
border-top-right-radius: 15px;
}
.on,a:hover{
background-color: palegreen;
color: white;
border-bottom: 2px solid red;
}
</style>
<script type="text/javascript">
window.onload=function(){
var aA = document.getElementsByTagName(a);
for(var i=0;i<aA.length;i++){
aA[i].onmouseover=function(){
clearInterval(this.time);
var This=this;
setInterval(function{
This.style.width=This.offsetWidth+8+"px";
if (This.offsetWidth>=180) {
clearInterval(This.time)
}
},30)
}
aA[i].onmouseout=function(){
clearInterval(this.time);
var This=this;
setInterval(function{
This.style.width=This.offsetWidth-8+"px";
if (This.offsetWidth<=120) {
this.style.width="120px";
clearInterval(This.time)
}
},30)
}
}
}
</script>
</head>
<body>
<ul>
<li><a class="on" href="#">Ke 闻</a></li>
<li><a href="http://www.imooc.com/">直 播</a></li>
<li><a href="#">军 事</a></li>
<li><a href="#">经 济</a></li>
<li><a href="#">国 际</a></li>
<li><a href="#">社 会</a></li>
</ul>
</body>
</html>