replace

UK[rɪˈpleɪs] US[rɪˈples]

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

with

英[wɪð] 美[wɪθ]

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

jquery replaceWith()方法 構文

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

##構文: $(selector).replaceWith(content)

##パラメータ:

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

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

# 構文:

$(selector).replaceWith(function())

パラメータ:

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

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

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

私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!