jQuery contents() 方法

jQuery 教程 · 2019-03-27 23:18:07

实例

查找 <div> 元素内所有的文本节点,并把它们用 <b> 元素包裹起来:

$("div").contents().filter("em").wrap("<b/>");

定义和用法

contents() 方法返回所有直接子元素,包括被选元素的文本和注释节点。

文本节点是由元素显示的实际文本。

该方法与 children() 方法类似,不同的是它返回的是文本和注释节点。如果在相同的域中,contents() 方法也能访问 iframe 的 HTML。

语法

$(selector).contents()

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

查看所有标签

The Art of Computer Programming, Volume 4,  Fascicle 3

The Art of Computer Programming, Volume 4, Fascicle 3

Donald E. Knuth / Addison-Wesley Professional / 2005-08-05 / USD 19.99

Finally, after a wait of more than thirty-five years, the first part of Volume 4 is at last ready for publication. Check out the boxed set that brings together Volumes 1 - 4A in one elegant case, and ......一起来看看 《The Art of Computer Programming, Volume 4, Fascicle 3》 这本书的介绍吧!

html转js在线工具
html转js在线工具

html转js在线工具

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具