jQuery .before()

jQuery .before() inserts content before target element; difference between .before() and .insertBefore();

<script>
$(function() {
    $('div').before($('<em>before text - </em>'));
    $('p').before($('<em>').attr('title', 'text title attr').text('before text with title attr - '));
});</script>
<div>div</div>
<p>paragraph</p>

Leave a Reply

Your email address will not be published. Required fields are marked *