how can $(this) not be the element that triggered the event in a jquery click handler?

后端 未结 3 1083
猫巷女王i
猫巷女王i 2021-01-19 11:42

I have a simple click handler

$(\'#test\').click( ev => {
   var $test = $(this);
   console.log($test         


        
3条回答
  •  悲&欢浪女
    2021-01-19 12:20

    Arrow functions do not bind this, arguments etc. MDN.

    An arrow function expression has a shorter syntax compared to function expressions and lexically binds the this value (does not bind its own this, arguments, super, or new.target).

提交回复
热议问题