现在的位置: 首页 > 综合 > 正文

jQuery学习

2013年08月10日 ⁄ 综合 ⁄ 共 825字 ⁄ 字号 评论关闭

1. jQuery, window.jQuery, window.$ or simply $ can be used interchangeably

 

2.  window.onload 和 $(document).ready(function())

 

    

// Override the onload event
window.onload = function(){

// the page finished loading, do something here...

}

 

This code actually overrides the onload event of the HTML <body> tag. All this means to us is that our code will be executed soon as the page is finished loading. It makes sense because sometimes pages take time to load, or the downloading process is segmented by the browser architecture.

 

 

The jQuery internal architecture also utilizes the window.onload event, but before it does so, it checks whether the entire DOM (document object model) has been loaded because it is very important. It is not enough for jQuery to know that the page has been loaded, we must ensure that the DOM has been fully constructed.

To provide us with this functionality, jQuery gives us a new method called ready that we can call on the main jQuery object itself.

抱歉!评论已关闭.