0

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

var thing = $('thing1')

and

var thing = document.getElementById('thing1')
PICyourBrain
  • 9,976
  • 26
  • 91
  • 136

1 Answers1

2

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

epascarello
  • 204,599
  • 20
  • 195
  • 236