In this article we will explain how to add text at the beginning of the selected elements in jquery or What is prepend() method in jquery or why use prepend() method in jquery with example. 


The jQuery prepend() method is used to add the specified content at the beginning of the selected elements. It is just the opposite of the jQuery append() method.If you want to add the content at the end of the selected elements, you should use the append method.


  • $(selector).prepend(“content”);
  • Example of jQuery prepend () method

Let's take an example to demonstrate jQuery prepend() Method.

 <!DOCTYPE html>
    <script src=""></script>
        $(document).ready(function () {
            $("#btn1").click(function () {
                $("p").prepend("<b>Prepended text</b>. ");
    <p>This is the tutorials point.</p>
    <p>This is the training point.</p>
    <button id="btn1">Prepend text</button>


how to add content beginning of selected elements

In above example when we click on button box Prepended text insert at the beginning

of the paragraph.


I hope this article will help to you.

 Let's check live example

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like