Tutorial by Examples

Solution 1: $('#parent').prepend($('#child')); Solution 2: $('#child').prependTo($('#parent')); Both solutions are prepending the element #child (adding at the beginning) to the element #parent. Before: <div id="parent"> <span>other content</span> </di...
prepend() - Insert content, specified by the parameter, to the beginning of each element in the set of matched elements. 1. prepend( content [, content ] ) // with html string jQuery('#parent').prepend('<span>child</span>'); // or you can use jQuery object jQuery('#parent').prepend(...

Page 1 of 1