jQuery replaceAll() Method

jQuery replaceAll() method replaces all selected elements with the new HTML elements.

jQuery replaceAll() method is similar to replaceWith() method, but there is one difference is in the syntax, placement of the content and target element.


Here is a syntax for the replaceAll() method

Parameter Type Description
content HTMLString Required Specifies the HTML content to insert.
selector Selector Required Specifies the selector expression, which elements to be replaced.


Here, in this example replaceAll() method call on selected elements when click on button.

<!DOCTYPE html>
  <title>jQuery replaceAll() method</title>
  <script src="jquery-latest.min.js"></script>
    <p class="param first">First paragraph start here...</p>
    <p class="param second">Second paragraph start here...</p>
    <p class="param third">Third paragraph start here...</p>
  <button>Click here to call replaceAll() method</button>

Run it...   »