jQuery after() Metode

❮ jQuery HTML/CSS-metodes

Voorbeeld

Voeg inhoud na elke <p>-element in:

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

Definisie en gebruik

Die after()-metode voeg gespesifiseerde inhoud in na die geselekteerde elemente.

Wenk: Om inhoud voor geselekteerde elemente in te voeg, gebruik die before() metode.


Sintaksis

$(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 dit self - voorbeelde


Voeg inhoud in met die after() metode.


Hoe om 'n funksie te gebruik om inhoud na geselekteerde elemente in te voeg.


❮ jQuery HTML/CSS-metodes