使用jQuery引用root html元素的最佳方法?

dal*_*ard 6 html jquery reference document-root

<html>在jQuery中获取根文档节点(元素)的最佳方法(性能方面)是什么?我可以想到几种可能有效或无效的方法:

$("html")

$(document.documentElement)

$(document) (?)

$.root (?)

$.document (?)

Jam*_*ice 14

$(document.documentElement)是最快的,相当一定的余地(见这里的测试).

通过查看jQuery源代码(查看init函数,特别是处理DOM元素的部分以及处理字符串的部分),您可以更深入地了解为什么会出现这种情况.