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

Related Posts

Leave a Reply

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

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.