jQuery replaceWith () method
Examples
The first <p> element with the new text:
$("button").click(function(){
$("p:first").replaceWith("Hello world!");
});
$("p:first").replaceWith("Hello world!");
});
try it"
Definition and Usage
replaceWith () method of the selected element is replaced with new content.
grammar
$(selector).replaceWith(content,function(index))
参数 | 描述 |
---|---|
content | 必需。规定要插入的内容(可包含 HTML 标签)。
可能的值:
|
function(index) | 可选。规定返回替换内容的函数。
|
More examples
Use function replaces the contents
How to use the function replaces the selected element is replaced with new content.