jQueryのreplaceWith()メソッド
例
新しいテキストの最初の<p>要素:
$("button").click(function(){
$("p:first").replaceWith("Hello world!");
});
$("p:first").replaceWith("Hello world!");
});
»をお試しください
定義と使用法
選択した要素のreplaceWith()メソッドは、新しいコンテンツに置き換えられます。
文法
$(selector).replaceWith(content,function(index))
参数 | 描述 |
---|---|
content | 必需。规定要插入的内容(可包含 HTML 标签)。
可能的值:
|
function(index) | 可选。规定返回替换内容的函数。
|
より多くの例
利用機能は、内容を置き換えます
関数を使用する方法選択した要素を新しいコンテンツで置き換えられる置き換えられます。