Вопрос

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

var thing = $('thing1')

and

var thing = document.getElementById('thing1')
Это было полезно?

Решение

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top