replace

英[r??ple?s]

vt. ???; ?? ???? ??;

with

英[ weekθ]

prep.With, with, with...

jqueryreplaceWith() ??? ???

??: replaceWith() ???? ??? ??? ??? HTML ??? ?? ??? ????. replacementWith()? replacementAll()? ??? ??? ????. ???? ??? ????. ???? ??? ??, ??? ??? ?? ???All() ??? ??? ? ????.

??: ??$(selector).replaceWith(content)

????:

ParametersDescription
content ?????. ??? ??? ??? ??? ?????. ??? ?: HTML ?? - ?: ("<div></div>") ? ?? - ?: (document.createElement("div")) ?? ?? - ?: ($(".div1")) ???? ?? ??? ?? ???? ?? ? ?????.
??? ?????. ??? ??? ?????.?

??? ???? ?? ??: ??? ???? ??? ??? ??? ???? ?????.

??: ??$(selector).replaceWith(function())

????:

???? Description
function()?????. ??? ??? ??? ? ???? ???? ?????.

jqueryreplaceWith() ??? ?

<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $(".btn1").click(function(){
    $("p").replaceWith("<b>Hello world!</b>");
  });
});
</script>
</head>
<body>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button class="btn1">用粗體文本替換所有段落</button>
</body>
</html>
???? ?? ?

??? ????? ??? "???? ??" ??? ?????