Skip to content
Related Articles

Related Articles

Improve Article

jQuery | prependTo() with Examples

  • Last Updated : 30 Aug, 2021

The prependTo() method is an inbuilt method in jQuery which is used to insert HTML elements or some content at the beginning of the selected element.



Parameters: This function accepts two parameters as mentioned above and described below: 

  • content: It is required parameter and used to specify the content to be inserted.
  • selector: It is required parameter and used to specify the elements to prepend the content.

Return Value: This method returns the selected element with the specific changes made by prependTo method.
Below example illustrate the prependTo() method in jQuery:


<!DOCTYPE html>
       <title>The prependTo Method</title>
      <script src=
      <!-- jQuery code to show the working of this method -->
                 $("<span>Welcome to </span>").prependTo("p");
         width: 350px;
         min-height: 180px;
         font-weight: bold;
         font-size: 25px;
         border: 2px solid green;
         <!-- Click on this button to see the change -->
         <button >Click Here!</button>



Related Articles: 

My Personal Notes arrow_drop_up
Recommended Articles
Page :