Loading…

Which one is more efficient, document.getElementbyId( "idname") or $("#idname)?

The document.getElementbyId( "ourID") is faster because it calls the JavaScript engine directly. jQuery is a wrapper that standardizes DOM control such that it works reliably in each significant browser. A jQuery object is built by the $ sign, and it will first parse the selector as jQuery can search things via attribute, class, etc. The document.getElementbyId can only find the elements by the id.

A jQuery object is actually not a native object so it takes time to create one and it additionally has considerably more potential.

Suggest An Answer

No suggestions avaliable!

Latest post from JQuery interview questions

Ask Question