滑动无反应,代码上没找到啥问题,请指点
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | <!doctype html> < html > < head > < meta charset = "UTF-8" > < title >777666</ title > < style > *{margin:0;padding: 0;} li{ width: 200px; height: 100px; background: #834; margin-bottom: 15px; list-style: none; } </ style > < script > window.onload=function(){ var ali = document.getElementsByName('li'); for(var i=0;i< ali.length ;i++){ ali[i] .onmouseover = function (){ moves(this,400); } ali[i] .onmouseout = function (){ moves(this,200); } } } var mytime; function moves(obj,tar){ clearInterval(mytime); mytime = setInterval (function(){ var speed=(tar-obj.offsetWidth)/10; speed =speed>0?Math.ceil(speed):Math.floor(speed); if(obj.offsetWidth==tar){ clearInterval(mytime); }else{ obj.style.width=obj.offsetWidth+speed+'px'; } },30) } </ script > </ head > < body > < ul > < li ></ li > < li ></ li > < li ></ li > < li ></ li > </ ul > </ body > </ html > |