Método jQuery insertAfter()

❮ Métodos jQuery HTML/CSS

Ejemplo

Inserte un elemento <span> después de cada elemento <p>:

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

Definición y uso

El método insertAfter() inserta elementos HTML después de los elementos seleccionados.

Sugerencia: para insertar elementos HTML antes de los elementos seleccionados, utilice el método insertBefore() .


Sintaxis

$(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

Pruébelo usted mismo - Ejemplos


Cómo usar el método insertAfter() para insertar un elemento existente después de cada elemento seleccionado.


❮ Métodos jQuery HTML/CSS