如何确定一个页面上有多少个jQuery对象? [英] how to determine how many jQuery objects are on a page?
本文介绍了如何确定一个页面上有多少个jQuery对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以确定页面上jQuery对象的数量吗?
Can I determine the number of jQuery objects on a page?
我想使用元素数量作为页面复杂性的弱基准.我在想,如果我可以减少jQuery知道的元素数量,则该页面可能会更有效地运行.
I want to use the number of elements as a sort of weak benchmark for page complexity. I'm thinking that if I can reduce the number of elements that jQuery knows about , the page might run more efficiently.
这有意义吗?
它像*选择并计算结果一样简单吗?
Is it as simple as doing a * select and counting the results?
推荐答案
var elementCount = $('*').size();
尽管这可能更是您想要的:
Although this might be more what you want:
var elementCount = $('body').find('*').size()
这篇关于如何确定一个页面上有多少个jQuery对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文