From jQuery JavaScript Library
« Back to Manipulation
replaceAll( selector )
Replaces the elements matched by the specified selector with the matched elements.
This function is the complement to
replaceWith() which does the same task with the parameters reversed.
Arguments:| selector | Selector | |
|---|
| The elements to find and replace the matched elements with. |
Examples:| Name | Type |
Replace all the paragraphs with bold words.
$("<b>Paragraph. </b>").replaceAll("p"); // check replaceWith() examples
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="../jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("<b>Paragraph. </b>").replaceAll("p"); // check replaceWith() examples
});
</script>
</head>
<body>
<p>Hello</p>
<p>cruel</p>
<p>World</p>
</body>
</html>