Skip to content
Justice Tech School

Clone, Wrap and Replace

clone copies elements, wrap puts a wrapper around them and replaceWith swaps them for something else.

Example
const $c = $('#row').clone();
$('p').wrap('<div class="box"></div>');
$('#old').replaceWith('<p>New</p>');

Exercise

Copy an element.

$('#r').()

Quiz Test

What does wrap do?

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