重要:js onclick() 函数中,取不到this !!!
错误的写法:
function test(){$(this).parent().addClass(‘active‘)}
正确的写法是:函数定义时带参数,调用时传入this
function test(param){$(param).parent().addClass(‘active‘)}
<button onclick="test(this)">
js/jquery this 坑
原文地址:https://www.cnblogs.com/dannyyao/p/10089930.html