Home>Article>Web Front-end> How to replace html content with jquery
Replacement method: 1. replaceWith() replaces the selected element with new content, the syntax is "$(selector).replaceWith(content)"; 3. replaceAll() uses the specified HTML content or element Replace selected elements, syntax "$(content).replaceAll(selector)".
The operating environment of this tutorial: windows7 system, jquery1.10.0 version, Dell G3 computer.
1. replaceWith()
Replace the selected content with the content in the brackets.
$("#div").replaceWith("div2");
Usage as above, replace the element with ID div with the DIV element with ID div2.
2. replaceAll()
Replace the selected content with the selector in brackets.
$("替换后的内容").replaceAll("p");
Usage as above, replace all p tags with the selected DIV tag.
Recommended related video tutorials:jQuery Tutorial(Video)
The above is the detailed content of How to replace html content with jquery. For more information, please follow other related articles on the PHP Chinese website!