Hello world!").replaceAll("p:last"); }); ``` ---"> Hello world!").replaceAll("p:last"); }); ``` ---" />
Easy Tutorial
❮ Jq Sel Element Prop Length ❯

jQuery replaceAll() Method

jQuery HTML/CSS Methods

Example

Replace the last <p> element with a <span> element:

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

Definition and Usage

The replaceAll() method replaces selected elements with new HTML elements.


Syntax

Parameter Description
content Required. Specifies the content to insert (must include HTML tags).
selector Required. Specifies which element(s) will be replaced.

jQuery HTML/CSS Methods

❮ Jq Sel Element Prop Length ❯