Javascript - arrow functions this in event handler?

前端 未结 4 1188
难免孤独
难免孤独 2020-11-22 16:54

I\'m new to ES6, and can\'t quite get this to work:

$(this) returns undefined on click?

dom.videoLinks.click((e) => {
            e.         


        
4条回答
  •  星月不相逢
    2020-11-22 17:19

    You can use $(event.target) instead of $(this) even inside of an arrow function. Arrow functions are preserving this of the scope where they were defined. In your case it is undefined.

提交回复
热议问题