jQuery replaceWith() 方法

jQuery 教程 · 2019-03-27 18:28:40

实例

把第一个 <p> 元素替换为新的文本:

$("button").click(function(){ $("p:first").replaceWith("Hello world!"); });

定义和用法

replaceWith() 方法把被选元素替换为新的内容。

语法

$(selector).replaceWith(content,function(index))

参数 描述
content 必需。规定要插入的内容(可包含 HTML 标签)。

可能的值:

  • HTML 元素
  • jQuery 对象
  • DOM 元素
function(index) 可选。规定返回替换内容的函数。
  • index - 返回集合中元素的 index 位置。

点击查看所有 jQuery 教程 文章: https://codercto.com/courses/l/35.html

查看所有标签

Machine Learning in Action

Machine Learning in Action

Peter Harrington / Manning Publications / 2012-4-19 / GBP 29.99

It's been said that data is the new "dirt"—the raw material from which and on which you build the structures of the modern world. And like dirt, data can seem like a limitless, undifferentiated mass. ......一起来看看 《Machine Learning in Action》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

MD5 加密
MD5 加密

MD5 加密工具