Skip to content
Justice Tech School

Add Elements

append and prepend add inside an element, after and before add outside. appendTo reverses the target.

Example
$('ul').append('<li>Last</li>');
$('ul').prepend('<li>First</li>');
$('p').after('<hr>');
$('<li>New</li>').appendTo('ul');

Exercise

Add at the start.

$('ul').('<li>1</li>')

Quiz Test

Which adds after the element?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.