Home/Jquery/.prepend() method in Jquery

.prepend() method in Jquery

Description:

The jQuery prepend() method is used to insert the content in the beginning of the selected elements.It will append the content as the first child of the selected element. It will app It just inverse of append() method.

Syntax

  • $(selector).prepend(content)
  • $(selector).prepend(content, function(index, html))
Content It specifies the content which need to append.
Function(index,html) It specifies the function that returns(HTML string, DOM element(s)) the content to insert.

Index: Returns the index position of the element.

HTML: Returns the current HTML of the selected element.

Example: 

Output: 

dotnet-helpers-com-jquery-prepend-method-thiyagu-dotnethelpers

Leave A Comment