为了账号安全,请及时绑定邮箱和手机立即绑定

怎么没效果呀?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>我的网站</title>

<style>

*{margin:0;padding:0;font-size:14px;}

ul{list-style:none;height:50px;padding-left:30px;border-bottom:5px solid #F60;}

li{float:left;margin-top:20px;}

a{text-decoration:none;display:block;height:30px;line-height:30px;width:120px;background-color:#ccc;margin-bottom:1px;text-align:center; }/* 删除下划线和文本缩进 */

.on,a:hover{color:#fff;background:#F60;height:30px;line-height:30px;}

</style>

<script>

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;

This.time=setInterval(function(){

This.style.width=This.offsetWidth+8+"px";

if(This.offsetWidth>=160){

 clearInterval(This.time)

}

  },30)

}

}

aA[i].onmouseout=function(){

clearInterval(This.time)

var This=this;

This.time=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="#">首&nbsp;&nbsp;页</a>

<li><a href="#">新闻快讯</a>

<li><a href="#">产品展示</a>

<li><a href="#">售后服务</a>

<li><a href="#">联系我们</a>

</ul>

</body>

</html> 


正在回答

2 回答

...

for(var i=0;i<aA.length;i++){

aA[i].onmouseover=function(){

clearInterval(This.time)

var This=this;

...

这里写了clearInterval(This.time),把它删掉,后面的鼠标移出代码也要删掉,并且把aA[i].onmouseout...放进for循环中。

0 回复 有任何疑惑可以回复我~

在img.onload里可以设置canvas的大小啊stringsplit()

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
导航条菜单的制作
  • 参与学习       123920    人
  • 解答问题       813    个

水平、垂直、圆角导航条菜单,让您的技术探索之路更高效

进入课程

怎么没效果呀?

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信