Question

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

var thing = $('thing1')

and

var thing = document.getElementById('thing1')
Was it helpful?

Solution

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.$

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top