jQuery :root 选择器
实例
将 HTML 文档的背景色设置为黄色:
<!DOCTYPE html><html><head><script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script><script>$(document).ready(function(){$(":root").css("background-color", "yellow");});</script></head><body><h1>这是一个标题</h1></body></html>
定义与用法
:root 选择器选择文档的根元素。
在 HTML 中, 根元素永远是 <html> 元素。
语法
$(":root")