Performance of jQuery Selectors with ID

后端 未结 9 2165
有刺的猬
有刺的猬 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:46

    I would say that the first one is the fastest because you're simply searching for one id.

    And

    $('#Mytbl .MyClass')
    

    is the slowest because you're not specifying the type of element that has the class "MyClass"

提交回复
热议问题