jQuery选择器优化问题,使用$('#a>.b'),IDE会提示这是低效的用法?
使用
$('#a>.b')
,提示:
Checks that jQuery selectors are used in an efficient way. It suggests to split descendant selectors which are prefaced with ID selector and warns about duplicated selectors which could be cached.
没看懂它说要干嘛,只看懂了说要把有id选择器为前缀的后代选择器分开来,然后说要缓存...那到底是要怎么分开来?
$('#a').find('.b')
这样吗?缓存的话,我只用到一次啊,没必要缓存啊
Aoist
10 years, 2 months ago