以逗号分隔的jQuery选择器性能 [英] Comma-separated jQuery selectors performance

查看:66
本文介绍了以逗号分隔的jQuery选择器性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告知在jQuery中使用选择器的方式更快:

Please advise which way using selectors in jQuery is faster:

$('.class1, .class2').html('');

$('.class1').html('');
$('.class2').html('');


推荐答案

用术语性能看起来几乎相同(7-8%),但就可维护性而言,第一种方法会更好,因为有没有重复的代码

In terms performance they seems to be almost same(7-8%), but in terms of maintainability the first method will be better since there is no duplication of code

这篇关于以逗号分隔的jQuery选择器性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆