Search code examples
jqueryscriptingnotice

jQuery Queue, how to create queue for notice system



I created a simple jQuery script, that's displays notification for users. This script is available on: jsfiddle.net/vLqQF/
I want to create queue, if I run 5 notice in short time, users dosnt see them. It's only working if prev is complete and hidden. I'm trying do a simple queue for that, but it seems to be more complicated. Anybody could help me?


Solution

  • Take a look at setInterval(). You can call your action and specify a time to wait:

    var interval = setInterval(function(){
        notice(1,1,'Hello World2');
    }, 2000);
    

    Then to clear the interval just use

    clearInterval(interval);
    

    This will clear the interval when you click the div

    Updated your fiddle:

    http://jsfiddle.net/vLqQF/4/