jQuery prepend and prependTo example

In this post,  we are going to see jQuery prepend and prependTo methods.

Both do the same task, insert text or html before content of every selected elements, so it will put text or html to first index of selected element. Both methods add text or html as a child to selected elements .Syntax is quite different for for prepend and prepend to nethod.
Syntax for prepend() :

inserting using prepend

Syntax for prependTo() :

inserting using prependTo

Let’s understand with the help of example:
Live demo: JS Bin on jsbin.com

Was this post helpful?

Leave a Reply

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