문제

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