Método jQuery replaceWith()
Ejemplo
Reemplace el primer elemento <p> con texto nuevo:
$("button").click(function(){
$("p:first").replaceWith("Hello world!");
});
Definición y uso
El método replaceWith() reemplaza los elementos seleccionados con contenido nuevo.
Sintaxis
$(selector).replaceWith(content,function(index))
Parameter | Description |
---|---|
content | Required. Specifies the content to insert (can contain HTML tags)
Possible values:
|
function(index) | Optional. Specifies a function that returns the content to replace
|
Pruébelo usted mismo - Ejemplos
Cómo usar una función para reemplazar elementos seleccionados con contenido nuevo.