我正在使用
noty来显示使用“右上角”警报设置的通知.我是jquery的新手,但知道php和mysql足以获得我想做的大部分事情.
我想要做的是使用mySQL获取数据,以查看用户是否需要显示任何通知(完成).然后显示页面加载的通知,我已经完成了,虽然我确定除了重复代码之外还有一种更优雅的方式来显示多个通知?
然后我想为每个通知显示1秒钟的延迟,这样它们就不会同时弹出,并且同时消失.我已经研究过.delay()但是我不知道jQuery好一点对我来说没用.
我的代码:
$(document).ready(function() {
var noty_id = noty({"text":"a message","layout":"topRight","type":"inormation","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":1000,"timeout":5000,"closeButton":false,"closeOnSelfClick":true,"closeOnSelfOver":false,"modal":false});
var noty_id = noty({"text":"a message","layout":"topRight","type":"inormation","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":1000,"timeout":5000,"closeButton":false,"closeOnSelfClick":true,"closeOnSelfOver":false,"modal":false});
});
最佳答案 您可以使用
setTimeout()
本机Javascript函数.这将在给定的超时时间(毫秒)后排队操作.
$(document).ready(function() {
var noty_id = noty({"text":"a message","layout":"topRight","type":"inormation","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":1000,"timeout":5000,"closeButton":false,"closeOnSelfClick":true,"closeOnSelfOver":false,"modal":false});
setTimeout(function() { var noty_id = noty({"text":"a message","layout":"topRight","type":"inormation","animateOpen":{"height":"toggle"},"animateClose":{"height":"toggle"},"speed":1000,"timeout":5000,"closeButton":false,"closeOnSelfClick":true,"closeOnSelfOver":false,"modal":false}); }, 5000)
});
您可以找到jQuery Pines更好的通知系统,用于排队多个通知.