Metoda jQuery insertAfter().
Příklad
Za každý prvek <p> vložte prvek <span>:
$("button").click(function(){
$("<span>Hello world!</span>").insertAfter("p");
});
Definice a použití
Metoda insertAfter() vloží prvky HTML za vybrané prvky.
Tip: Chcete-li vložit prvky HTML před vybrané prvky, použijte metodu insertBefore() .
Syntax
$(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 |
Zkuste si to sami - příklady
Jak použít metodu insertAfter() k vložení existujícího prvku za každý vybraný prvek.