Reputation: 150303
I want to to execute the handlers I pass to the "ready" function in the order there were inserted.
I saw with a jsFiddle that the order is opposite- LIFO - like a stack.
Is there a way to execute in order of FIFO like a queue?
(obviously I can't just insert the handlers in opposite order...)
Upvotes: 0
Views: 136
Reputation: 41767
They will be executed in the order that they were inserted by default.
The reason why the fiddle you saw looks like a LIFO stack is because the after
method adds the number directly after the element with id 'logs'. So 1 gets added first, so the text looks like:
Text: The Log: 1
HTML: <div id=log><label id="logs"> The Log: </label>1</div>
Then 2 gets added directly after logs:
Text: The Log: 21
HTML: <div id=log><label id="logs"> The Log: </label>21</div>
... continuing up to:
Text: The Log: 4321
HTML: <div id=log><label id="logs"> The Log: </label>4321</div>
See here for your fiddle with alerts so you can see the order more clearly.
Upvotes: 3