Método jQuery insertAfter()
Exemplo
Insira um elemento <span> após cada elemento <p>:
$("button").click(function(){
$("<span>Hello world!</span>").insertAfter("p");
});
Definição e uso
O método insertAfter() insere elementos HTML após os elementos selecionados.
Dica: Para inserir elementos HTML antes dos elementos selecionados, use o método insertBefore() .
Sintaxe
$(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 |
Experimente você mesmo - Exemplos
Como usar o método insertAfter() para inserir um elemento existente após cada elemento selecionado.