jQuery insertAfter() Metode
Voorbeeld
Voeg 'n <span>-element na elke <p>-element in:
$("button").click(function(){
$("<span>Hello world!</span>").insertAfter("p");
});
Definisie en gebruik
Die insertAfter()-metode voeg HTML-elemente na die geselekteerde elemente in.
Wenk: Om HTML-elemente voor die geselekteerde elemente in te voeg, gebruik die insertBefore() metode.
Sintaksis
$(content).insertAfter(selector)
Parameter | Description |
---|---|
content | Required. Specifies the content to insert (must contain HTML tags). Note: If content is an existing element, it will be moved from its current position, and inserted after the selected elements. |
selector | Required. Specifies where to insert the content |
Probeer dit self - voorbeelde
in Hoe om die insertAfter() metode te gebruik om 'n bestaande element na elke geselekteerde element in te voeg.