Javascript “this” reference for onclick event not working

后端 未结 4 1874
独厮守ぢ
独厮守ぢ 2020-12-06 18:18

I\'m trying to call a function with the \"onclick\" event as so:




        
4条回答
  •  长情又很酷
    2020-12-06 18:46

    this is the window object in your code.

    You could pass this as the parameter.

    
    

    then:

    function move(ele){
        var myId = ele.id;
        alert("myId");
    }
    

提交回复
热议问题