Home >>jQuery Tutorial >jQuery replaceAll() Method

jQuery replaceAll() Method

jQuery replaceAll() Method

jQuery replaceAll() method in jQuery is an inbuilt method and is used to add new HTML elements that replaces the selected elements.


Parameter Values

Parameter Description
content It is required parameter to specify the content to insert
selector It is a required parameter and is used to Specifies which elements to be replaced
Here is an Example of jQuery replaceAll() Method:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
$("<h3>Hello Phptpoint!!</h3>").replaceAll(".txt1");
<button class="btn1">Replace all p elements with h3 elements</button><br>
<p class="txt1">This is First paragraph.</p>
<p class="txt1">This is Second paragraph.</p>
<p class="txt1">This is Third paragraph.</p>


This is First paragraph.

This is Second paragraph.

This is Third paragraph.