当我使用下面的内容时,我无法让jQuery this隐藏元素.
$('.purplePanda').click(function(e){
this.hide();
});
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Uncaught TypeError: this.hide is not a function
更换
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)
请参阅此处的官方文档