---
title: "jquery 控制 replaceAll( selector ) "
author: "KAXU"
date: "2009-02-03T16:14:37Z"
tags: []
slug: "jquery-replaceall-selector"
draft: false
lastmod: "2009-02-03T16:14:37Z"
id: 322516
url: "https://kaxu.iteye.com/blog/322516"
---

replaceAll( selector )

将匹配元素集合替换选中的匹配元素集合中每一个元素。

```
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="http://code.jquery.com/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>
```

 

 $("&lt;b&gt;Paragraph. &lt;/b&gt;").replaceAll("p"); // check replaceWith() examples  
将"&lt;b&gt;Paragraph. &lt;/b&gt;"替换匹配p元素集合中每一个p元素