Performance of jQuery Selectors with ID

后端 未结 9 2200
有刺的猬
有刺的猬 2021-01-12 10:52

I know in jQuery if we use ID to select elements,it\'s so efficient.I have a question about this selectors:

please consider this 3 selectors:

         


        
9条回答
  •  灰色年华
    2021-01-12 11:40

    The fastest will be:

      $('#Mytbl', '#MytblContainer' );    
    

    because in this case, jquery don't have to search the whole dom tree to find '#Mytbl'. It will search in the scope given only. IE it will serach in '#MytblContainer' only .

提交回复
热议问题