javascript - jquery: $ ("???") 何时扫描整个 DOM?

标签 javascript jquery

当使用$("#xxx")时,我猜jQuery在幕后使用getElementById

$(".xxx")每次都会扫描整个 DOM 吗?

最佳答案

jQuery 尝试使用最快的选择方法来获取您所要求的内容。有许多很好的资源以及与 jQuery 直接相关的性能优化技巧:

Good ways to improve jQuery selector performance?

http://www.artzstudio.com/2009/04/jquery-performance-rules/

http://www.componenthouse.com/article-19

http://www.learningjquery.com/2006/12/quick-tip-optimizing-dom-traversal

关于javascript - jquery: $ ("???") 何时扫描整个 DOM?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1467834/

相关文章:

javascript - AngularUi jQuery Passthrough - 调用方法获取插件值

javascript - jQuery DataTables - 自定义列可见性

javascript - 如果 Div 为空,隐藏它并改变另一个 div 的宽度

javascript - 使用 apollo-datasource-rest 从响应中读取 header

javascript - firebase firestore 从文档中获取对象/数组 - js

javascript - 从 JavaScript 检测以 headless 模式运行的 Chrome

javascript - 如果 li 类等于则添加超链接

javascript - Bootstrap 中的弹出窗口

javascript - 传递 HTML 值以在 JQuery UI 对话框中使用?

javascript - JS/jQuery : fire onchange from a disabled/readonly input without using button