0

私はjavascriptを学び、RightJSを使用しています。次の違いは何ですか?

var thing = $('thing1')

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

1 に答える 1

2

ブラウザのコンソールに入力します

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

$ がある種のラップされたオブジェクトを返し、getElementById が Html Node を返すことがわかります。

Util.$でドキュメントをチェックしてください。

于 2013-05-23T17:04:01.323 に答える