为什么以下代码不起作用?只有延迟淡出才有效。不是点击事件。如果我评论自动淡出,则单击事件正在运行。我怎么能缩短代码呢?
感谢您的帮助! :)
var wooMessage = $('.woocommerce-message');
var wooError = $('.woocommerce-error');
wooMessage.delay(9000).fadeOut(160);
wooError.delay(9000).fadeOut(160);
$('.woocommerce-message-close').click(function() {
wooMessage.fadeOut(160);
});
$('.woocommerce-error-close').click(function() {
wooError.fadeOut(160);
});
答案 0 :(得分:2)
var wooMessage = $('.woocommerce-message');
var wooError = $('.woocommerce-error');
wooMessage.delay(9000).fadeOut(160);
wooError.delay(9000).fadeOut(160);
$('.woocommerce-message-close').click(function() {
wooMessage.stop().fadeOut(160);
});
$('.woocommerce-error-close').click(function() {
wooError.stop().fadeOut(160);
});