Home/Jquery/.after() method in Jquery

.after() method in Jquery

Description:

The jQuery after() method is used to insert content after the selected element.

Syntax

  • $(selector).after(content)
  • $(selector).after(content,function(index))
Content It specifies the content which need to append.
Function(index) It specifies the function that returns the content which used to insert.

index: Get the index position of the element in the set

Passing Function:

.after() supports passing a function that returns the elements to insert like as below. It can accept any number of additional arguments.

Example: 

Output: 

By clicking the button, “this is Newly added text” will append after the selected div (divcontainer).

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

 

Leave A Comment