.replaceWith( newContent ): Replace all matching elements in the collection with the provided content and return the collection of deleted elements. How to return the collection of deleted elements? -PHP Chinese website Q&A-.replaceWith(newContent): Replace all matching elements in the collection with the provided content and return the collection of deleted elements. How to return the collection of deleted elements? -PHP Chinese website Q&A
.replaceWith( newContent ): Replace all matching elements in the collection with the provided content and return the collection of deleted elements. How to return the collection of deleted elements? -PHP Chinese website Q&A-.replaceWith(newContent): Replace all matching elements in the collection with the provided content and return the collection of deleted elements. How to return the collection of deleted elements? -PHP Chinese website Q&A
Please watch and learn.
设置一个变量用.replaceWith( newContent )返回值赋值就可以看到被删除元素了,比如例子中添加del变量如下:
var del = $(".right > div:first p:eq(1)").replaceWith('replaceWith替换第二段的内容');
document.write(del.html());
可以看到打印“第二段”就是返回值了