Boyan Georgiev
Boyan Georgiev

Reputation: 1551

JavaScript callback/closure/other

I have the below piece of code:

$("some_html_stuff").insertAfter('.some_element');

I then have other JS code which I need to be sure will execute AFTER the insertAfter function has finished its business. How can a achieve this? I looked at closures and a bunch of other stuff, but I don't seem to be able to figure this out.

Upvotes: 1

Views: 94

Answers (2)

Ben Lee
Ben Lee

Reputation: 53319

This is a synchronous command. Nothing further will execute until it's finished.

$("some_html_stuff").insertAfter('.some_element');
// Do something after

Upvotes: 2

bfavaretto
bfavaretto

Reputation: 71908

.insertAfter is not asynchronous, so just add your other code right after that line of code.

Upvotes: 1

Related Questions