prepend() method in jQuery

prepend() in jQuery

This method is used to insert content at the beginning of each element in the set of specified matched elements.

Syntax 1


  • content - HTML string, DOM element, text node, array of elements and text nodes, or jQuery object to be inserted before each element in the set of matched elements.
Syntax 2


  • index - Index position of the element in the set.
  • currentElement - old HTML value of the element.

Example 1

Try Yourself

Example 2 - multiple content

Try Yourself

Example 3 - html content

Try Yourself

Example 4 - content through function

Try Yourself