总有人间一两风,填我十万八千梦

jQuery .:root Selector 用法 手册 | 示例代码

jQuery开发手册 归档 608℃ 0评论

描述: 选择该文档的根元素。

  • 添加的版本: 1.9jQuery( “:root” )

在HTML中,文档的根元素,和$(":root")选择的元素一样, 永远是<html>元素。

例子:

显示根元素的标签名。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<!DOCTYPE html>
<html>
<head>
<style>
span.fot { color: red; font-size: 120%; font-style: italic; }
</style>
<script src="https://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<div id="log">The root of this document is: </div>
<script>
$( "<b></b>" ).html( $( ":root" )[0].nodeName ).appendTo( "#log" );
</script>
</body>
</html>

转载请注明:悠然品鉴 » jQuery .:root Selector 用法 手册 | 示例代码

喜欢 (0)or分享 (0)
发表我的评论
取消评论

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址