错误的,这里使用了const声明,常量不能改
$('.quote_js').click(function(){
console.log('点击引用');
shakeBox.addClass('shakeAnimate')
const shakeTimer = setTimeout(() => {
shakeBox.removeClass('shakeAnimate')
clearTimeout(shakeTimer)
}, 500);
})
正确的,用let
$('.quote_js').click(function(){
console.log('点击引用');
let shakeBox = $(this);
shakeBox.addClass('shakeAnimate');
// 存储定时器的引用
let shakeTimer = setTimeout(() => {
shakeBox.removeClass('shakeAnimate');
// 清除定时器
clearTimeout(shakeTimer);
}, 500);
});