jQuery after() Methode

❮ jQuery HTML/CSS-methoden

Voorbeeld

Voeg inhoud in na elk <p> element:

$("button").click(function(){
  $("p").after("<p>Hello world!</p>");
});

Definitie en gebruik

De methode after() voegt gespecificeerde inhoud in na de geselecteerde elementen.

Tip: Gebruik de methode before() om inhoud in te voegen vóór geselecteerde elementen.


Syntaxis

$(selector).after(content,function(index))

Parameter Description
content Required. Specifies the content to insert (can contain HTML tags)

Possible values:

  • HTML elements
  • jQuery objects
  • DOM elements
function(index) Specifies a function that returns the content to insert
  • index - Returns the index position of the element in the set

Probeer het zelf - Voorbeelden


Voeg inhoud in met de methode after().


Een functie gebruiken om inhoud in te voegen na geselecteerde elementen.


❮ jQuery HTML/CSS-methoden