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...)
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.