【发布时间】:2011-03-01 15:20:20
【问题描述】:
这是针对返回者的,作为 PHP 驱动的 CMS 的一部分。
我们希望返回者(如果有类 admin)添加 div hide,这是一个小 X 按钮。返回者应该在 4 秒后自动淡出(),或者如果用户点击 hide 按钮,返回淡出()。
每个 //HERE 代码都单独运行,但它们一起只会运行延迟的 fadeOut() 而而不是被点击的代码!
任何帮助都会很棒。谢谢,尼克。
$(".success, .info, .warning, .error").each(function(){
if(!$(this).hasClass("admin")){
$(this).append('<div class="hide"></div>');
$(this).delay(4000).fadeOut(); // HERE
}
});
$(".hide").click(function(){
$(this).parent().fadeOut(); // HERE
});
【问题讨论】: