Description
The .replaceAll() method replaces selected elements with new content.
Tip: The replaceWith() and replaceAll() methods do the same thing. The difference is in the syntax: the placement of the content and selector, and that replaceWith() can replace content using a function.
v1.2
This method has the form:
$(content).replaceAll(selector)
Parameter | Description |
---|---|
content | (required) Specifies the new content. Possible values:
|
selector | (required) Specifies which elements to be replaced |
Return Value
This form returns a jQuery object.
Examples
Replace each p element with some bold text:
$("button").click(function(){
$("p").replaceAll(
"<b>jQuery</b>");
});