各路大神幫我看下這個(gè)單物體運(yùn)動錯(cuò)了那
?window.onload=function(){
? ? ? ?var li=Document.getElementsByTagName("ali");
? ? ? ?ali.onmousemover()=function(){
? ? ? ? ? ?startMove(this,400);
? ? ? ?}
? ? ? ?ali.onmouseout=function(){
? ? ? ? ? ?startMove(this,200);
? ? ? ?}
? ?}
? ?var ? timer = null;
? ?function stratMove(obj,iTarget){
? ? ? ?clearInterval(obj.timer);
? ? ? ?var speed=(iTarget-obj.offsetwidth)/8;
? ? ? ?speed=speed>0?Math.ceil(speed):Math.floor(speed);
? ? ? ?obj.timer=setInterval(function(){
? ? ? ? ? ?if(obj.offsetwidth==iTarget){
? ? ? ? ? ? ? ?clearInterval(obj.timer);
? ? ? ? ? ?}
? ? ? ? ? ?else{
? ? ? ? ? ? ?obj.style.width=obj.offsetwidth+speed+'px';
? ? ? ? ? ?}
? ? ? ?},30)
? ?}
</script>
2016-08-28
?var li=Document.getElementsByTagName("ali");
? ? ? ?ali.onmousemover()=function(){
? ? ? ? ? ?startMove(this,400);
? ? ? ?}
? ? ? ?ali.onmouseout=function(){
? ? ? ? ? ?startMove(this,200);
? ? ? ?}
? ?}
你這里用變量li獲取了ali了要遍歷一次啊,而且是用li【i】來調(diào)用事件onmouseover和onmouseout的
2016-11-29
是document.getElementsByTagName吧
2016-09-08
ali[0].onmousemover()=function(){
? ? ? ? ? ?startMove(this,400);
? ? ? ?}
這樣試試呢