Home >>jQuery Tutorial >jQuery before() Method

jQuery before() Method

jQuery before() Method

jQuery before() method


Parameter Values

Parameter Description
content It is a Required parameter used to insert the specifies content (can contain HTML tags)

Possible values:

  • HTML elements
  • jQuery objects
  • DOM elements
function(index) It is used to returns the specifies content to insert
  • index – used to Returns the set of index position in the element
Here is an example of jQuery before() Method:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
$(".txt1").before("<p>Hello Phptpoint!</p>");
<button class="btn1">click to insert content</button>
<p class="txt1">PHPTPOINT</p>
<p class="txt1">This is a paragraph.</p>



This is a paragraph.

No Sidebar ads