jQuery方法不在事件处理程序中处理'this'

2 html jquery

当我使用下面的内容时,我无法让jQuery this隐藏元素.

$('.purplePanda').click(function(e){
   this.hide();
});
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

Uncaught TypeError: this.hide is not a function

Lal*_*Lal 6

更换

this.hide(); 
Run Code Online (Sandbox Code Playgroud)

$(this).hide();
Run Code Online (Sandbox Code Playgroud)

因此你的功能应该是这样的

$('.purplePanda').click(function(e){
   $(this).hide();
});
Run Code Online (Sandbox Code Playgroud)

请参阅此处的官方文档