jQuery中窗口和文档的区别 [英] difference between window and document in jQuery
问题描述
我想知道文档和&& window 在jQuery中
这两个常用,但我从来没有得到它们之间的区别。
。 。这实际上可能是你意识到的一个更大的问题。 :)
非常简短的答案是。 。 。
$ b
窗口
对象代表文档
对象被显示出来。事实上,当你在你的代码中引用 document
时,你确实引用了 window.document
( window
的所有属性和方法都是全局的,因此可以在开始时没有真正指定 window ...例如
文档
= window.document
和 alert()
= window.alert()
)。
$ b
对于两个对象(包括标准属性和方法)的大量信息,请查看这些链接: 最后一个注意:虽然不完全准确,但如果您是视觉人物,您可以考虑 i wanna know whats the difference between document && window in jQuery ?? These two are used quite often, but i hv never got the difference between them. Whew . . . that's actually probably a bigger question that you realize. :) The Extremely Short Answer is . . . The The For LOTS of information on the two objects (including standard properties and methods), check out these links: One last note: While not completely accurate, if you are a visual person, you can think of the 这篇关于jQuery中窗口和文档的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! c $ c> object是当前加载的DOM文档。 。 。所以,如果你去 http://www.stackoverflow.com ,
文档
对象将被加载构成StackOverflow主页的所有HTML,JS,CSS等。如果您点击此问题的链接,那么文档
现在都是构成此问题页面的相同类型的资产。但是,当您更改文档
时,您仍然位于窗口
中(尽管<$ c的一些属性
窗口
object - https://developer.mozilla.org/zh-CN/docs/Web/API/Window
文档
object - https://developer.mozilla.org/en-US/docs/Web/API/document
窗口
作为您打开浏览器窗口或选项卡查看网页。 。 。您可能会在浏览时浏览很多文档
,但是,如果您从未更改为其他选项卡,则始终位于窗口
。window
object represents the container that the document
object is displayed in. In fact, when you reference document
in your code, you are really referencing window.document
(all properties and methods of window
are global and, as such, can be referenced without actually specifying window
at the beginning . . . e.g., document
= window.document
and alert()
= window.alert()
).document
object is the currently loaded DOM document . . . so, if you go to http://www.stackoverflow.com, the document
object would be all of the HTML, JS, CSS, etc. that are loaded to make up the StackOverflow home page. If you click on the link to this question, the document
is now all of the same kinds of assets that make up the page for this question. When you change documents
though, you are still in the same window
(though some of the properties of the window
have changed).
window
object - https://developer.mozilla.org/en-US/docs/Web/API/Window document
object - https://developer.mozilla.org/en-US/docs/Web/API/documentwindow
as the browser window or tab that you have open to view web pages . . . you may move through many document
s as you are surfing, but, if you never change to a different tab, you are always in the same window
.