问答详情
源自:5-1 JS链式动画

报错:Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'

li1.onmouseover=function(){ 
    startMove(li1,"height",300,function(){        
        startMove(this,"width",600);      
       });    
     };

如果第二层函数里面写this而不懈li1就回报这个错,这是为什么呢?

提问者:sUcK_lOlIpOp 2019-01-07 21:26

个回答

  • 慕粉0815224883
    2019-01-09 10:44:12
    已采纳

    回调函数 不可用this  可以在前面声明一个 var that=this;将this赋予that。

  • 慕无忌4172087
    2020-03-25 16:32:06

    用that也没有效果啊

  • qq_GoodForNothi_1
    2019-02-03 00:25:06

    不是不能用this。。。而是你那个指代的并不是个元素,你看报错信息就知道了,你是想给元素设置动画不是给window 设置。。