What is the difference between append(), prepend(), after() and before()?

<ul id="l"><li>Middle</li></ul>
$('#l').append('<li>End</li>').prepend('<li>Start</li>');
$('#l').after('<p>After</p>').before('<p>Before</p>');
HTML after the code runs

<p>Before</p>
<ul id="l">
<li>Start</li>
<li>Middle</li>
<li>End</li>
</ul>
<p>After</p>

See Add Elements.


Learn more about the similar topics:
Tutorials
No Content Found.
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.