Example 1 — Official Demo: Replace All Paragraphs
Swap every <p> for a bold “Paragraph.” element.
// <p>Hello</p><p>cruel</p><p>World</p>
$("p").replaceWith("<b>Paragraph.</b>"); How It Works
- Select. Every
pis in the matched set. - Content. An HTML string builds the bold replacement.
- Swap. Each paragraph is removed; bold fills its slot.

