Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

document.getelementbyid vs dom.byid

Here is some code

  var docDiv= document.getElementById("divId");

  var dojoDiv= dom.byId("divId");

what are difference between javascript's document.getelementbyid and dojo's dom.byid. which is one more faster. if you want to use dom we need to load dojo.js.

like image 366
Vhasure Prashant Avatar asked Apr 14 '26 22:04

Vhasure Prashant


1 Answers

Here is the non IE version of Dojo's dom.byId :

dom.byId = function(id, doc){
            // inline'd type check.
            // be sure to return null per documentation, to match IE branch.
            return ((typeof id == "string") ? (doc || win.doc).getElementById(id) : id) || null; // DOMNode
        };

As you will note it uses getElementById.

Hope this answers your question.

like image 54
HBP Avatar answered Apr 16 '26 10:04

HBP