RightJS: getElementById vs $('element_id')

72 Views Asked by At

I am learning javascript and using RightJS. What is the difference between the following?

var thing = $('thing1')

and

var thing = document.getElementById('thing1')
1

There are 1 best solutions below

0
On BEST ANSWER

Type it into the browser's console

> $("head")
  by {_: div#head, constructor: function, initialize: function, parent: function, parents: function…}
> document.getElementById("head");
  <div id=​"head">​…​</div>​

You can see the $ returns some sort of wrapped object and that getElementById returns an Html Node.

Check out their docs on Util.$