jQuery .prepend()

jQuery .prepend() inserts content to the beginning of the target; difference between .prepend() and .prependTo();

js:


$(function() {

    $('div').prepend($('<em>prepend text - </em>'));

    $('p').prepend($('<em>').attr('title', 'text title attr').text('prepend text with title attr - '));

});​

html:


<div>div</div>

<p>paragraph</p>​

Leave a Comment