jQuery has an .after()
method, and also an .insertAfter()
method.
What\'s the difference between them? I think I can use .after()
All of the answers so far are clear as mud ;-) (So I'll take a stab at it too!)
If you start off with this Html:
Para 1
Para 2 More
After inserts some new content after the matching tags:
$("p") // Match all paragraph tags
.after("Hello"); // Insert some new content after the matching tags
The end result is:
Para 1
Hello
Para 2 More
Hello
On the other hand, InsertAfter moves one or more elements which already exist on the DOM after the selected elements (Really, this method could be called MoveAfter):
$("#sMore") // Find the element with id `sMore`
.insertAfter("#pOne"); // Move it to paragraph one
Resulting in:
Para 1
More
Para 2