0

Possible Duplicate:
In jQuery, is selecting by class or id faster than selecting by some other attribute?

I am very much new to jquery and a bit confused with so many options after searching different forums. Can you please advice which one is faster and most optimized way to select an element in jquery?

1) by id [normally I use this one]

$("#thisID")

2) by name

$("input[name=thisName]")

3) by type followed by id [Not sure whether this is right syntax or not]

$("select #thisID)

Thanks,

Community
  • 1
  • 1
abdfahim
  • 2,523
  • 10
  • 35
  • 71

1 Answers1

0

selecting an element by ID is way faster than any other method.

The performance will depend by the browser you're using due to the differences in DOM manipulation.

Roko C. Buljan
  • 196,159
  • 39
  • 305
  • 313