Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery after() method

jQuery after() method

jQuery HTML/CSS methods jQuery HTML/CSS methods

Example

Insert content after each

element:

$

(

"

button

"

)

.

click

(

function

(

)

{

$

(

"

p

"

)

.

after

(

"

Hello world!

"

)

;

}

)

;

Try it »


Definition and Usage

The after() method inserts the specified content after the selected elements.

**Tip:** To insert content before the selected elements, use before() method.


Syntax

$(

selector

).after(

content

,function(

index

))

Parameters Description
content Required. Specifies the content to insert (may contain HTML tags).

Possible values:

  • HTML element
  • jQuery object
  • DOM element
  • | | function(*index*) | Specifies a function that returns the content to insert. |

    More examples

    after() - creating content with HTML, jQuery, and DOM
    Inserting content with the after() method.

    Inserting content using a function
    How to use a function to insert content after the selected elements.


    jQuery HTML/CSS methods jQuery HTML/CSS methods