replace

UK[r??ple?s] US[r??ples]

vt. 置き換える; 置き換える;...を元の位置に戻す; (...を使用する)

with

英[w?e] 美[w?θ]

prep.With;and,with;about;consistent with...

jquery replaceWith()方法 構(gòu)文

関數(shù): replaceWith() メソッドは、選択した要素を指定された HTML コンテンツまたは要素に置き換えます。 replaceWith() は replaceAll() と同じ効果があります。違いは構(gòu)文にあり、セレクターの內(nèi)容と位置が異なり、置換には replaceAll() 関數(shù)を使用できません。

##構(gòu)文: $(selector).replaceWith(content)

##パラメータ:

パラメータコンテンツ セレクター
説明
必須。選択した要素を置き換えるコンテンツを指定します??赡埭蕚? HTML コード - 例: ("
gt;
") 新しい要素 - 例: (document.createElement("div")) 既存の要素 - 例: ($(".div1")) 既存の要素は移動することはできません。選択した要素をコピーしてラップするだけです。
必須。置換する要素を指定します。
関數(shù)を使用して要素を置き換えます:

関數(shù)を使用して、選択した要素を新しいコンテンツに置き換えます。

# 構(gòu)文:

$(selector).replaceWith(function())

パラメータ:

パラメータfunction()
説明
必須。選択した要素を置き換える新しいコンテンツを返す関數(shù)。 #####################################

jquery replaceWith()方法 例

<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>
インスタンスの実行 ?

[インスタンスの実行] ボタンをクリックしてオンライン インスタンスを表示します

<thead id="lz4kz"></thead>