Does jQuery do any kind of caching of “selectors”?

后端 未结 14 2167
挽巷
挽巷 2020-11-27 18:14

For example, will the first piece of code perform a full search twice, or is it smart enough to cache results if no DOM changes have occurred?

if ($(\"#navba         


        
14条回答
  •  孤城傲影
    2020-11-27 18:52

    I don't think it does (although I don't feel like reading through three and a half thousand lines of JavaScript at the moment to find out for sure).

    However, what you're doing does not need multiple selectors - this should work:

    $("#navbar .heading:not(:empty)").hide();
    

提交回复
热议问题