亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

請問為什么沒有效果了??不知都哪里出錯了。

<!DOCTYPE HTML>
<html>
<head>
?? ?<title>多物體動畫</title>
?? ?<meta charset="UTF-8">
?? ?<style type="text/css">
?? ??? ?*{
?? ??? ??? ?padding: 0px;
?? ??? ??? ?margin: 0px;
?? ??? ?}
?? ??? ?ul{
?? ??? ??? ?list-style: none;
?? ??? ?}
?? ??? ?ul li{
?? ??? ??? ?width: 130px;
?? ??? ??? ?height: 100px;
?? ??? ??? ?background:#F33;
?? ??? ??? ?margin-top:15px;
?? ??? ?}
?? ?</style>
?? ?<script type="text/javascript">
?? ??? ?window.onload=function(){
?? ??? ?//事件監聽
?? ??? ?var aLi = document.getElementsByTagName('li');?? ??? ??? ?
?? ??? ?for(var i=0;i<aLi.length;i++){?? ??? ??? ?
?? ??? ??? ?aLi[i].onmouseover = function (){
?? ??? ??? ??? ?move2(this,400);
?? ??? ??? ?}
?? ??? ??? ?aLi[i].onmouseout = function (){
?? ??? ??? ??? ?move2(this,130);
?? ??? ??? ?}
?? ??? ?? }?? ??? ?
?? ??? ?}
?? ??? ?//動畫函數
?? ??? ?? //var timer=null;
?? ??? ?? function move2(obj,Target){
?? ??? ? ??? ?clearInterval(obj.timer);
?? ??? ? ??? ?obj.timer = setInterval(function(){
?? ??? ? ??? ?var speed = (Target-obj.offsetWidth)/8;
?? ??? ? ??? ??? ?speed = speed>0?Math.ceil(speed):Math.floor(speed);
?? ??? ? ??? ??? ?if(obj.offsetWidth==Target){
?? ??? ? ??? ??? ??? ?clearInterval(obj.timer);//運動到指定位置后清除計時器
?? ??? ? ??? ??? ?}else{
?? ??? ? ??? ??? ??? ?obj.style.width = obj.offsetWidth+speed+'px';
?? ??? ? ??? ??? ?},30);
?? ??? ?? }?? ??? ??? ??? ?
?? ?</script>
</head>
<body>
?? ?<ul>
?? ??? ?<li><a href="#"></a></li>
?? ??? ?<li><a href="#"></a></li>
?? ??? ?<li><a href="#"></a></li>
?? ?</ul>
</body>
</html>

正在回答

2 回答

<!DOCTYPE?HTML>
<html>
<head>
????<title>多物體動畫</title>
????<meta?charset="UTF-8">
????<style?type="text/css">
????????*{
????????????padding:?0px;
????????????margin:?0px;
????????}
????????ul{
????????????list-style:?none;
????????}
????????ul?li{
????????????width:?130px;
????????????height:?100px;
????????????background:#F33;
????????????margin-top:15px;
????????}
????</style>
????<script?type="text/javascript">
????????window.onload=function(){
????????//事件監聽
????????var?aLi?=?document.getElementsByTagName('li');
????????for(var?i=0;?i?<?aLi.length;?i++){????????????
????????????aLi[i].onmouseover?=?function?(){
????????????????move2(this,?400);
????????????}
????????????aLi[i].onmouseout?=?function?(){
????????????????move2(this,?130);
????????????}
??????????}????????
????????}
????????//動畫函數
??????????//var?timer=null;
??????????function?move2(obj,Target){
??????????????clearInterval(obj.timer);
??????????????obj.timer?=?setInterval(function(){
??????????????????var?speed?=?(Target-obj.offsetWidth)/8;
??????????????????speed?=?speed?>?0???Math.ceil(speed)?:?Math.floor(speed);
??????????????????if(obj.offsetWidth==Target){
??????????????????????clearInterval(obj.timer);//運動到指定位置后清除計時器
??????????????????}else{
??????????????????????obj.style.width?=?obj.offsetWidth+speed+'px';
??????????????????}
??????????????},?30)
??????????}??????????????
????</script>
</head>
<body>
????<ul>
????????<li><a?href="#"></a></li>
????????<li><a?href="#"></a></li>
????????<li><a?href="#"></a></li>
????</ul>
</body>
</html>

setInterval的函數沒有寫正確。時間設置在else上面了

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

看看錯誤的提示位置,指示仔細檢查格式

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

舉報

0/150
提交
取消

請問為什么沒有效果了??不知都哪里出錯了。

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號