jQuery page load and compare event of jQuery and JavaScript

1, jQuery Overview

  jQuery is a JavaScript library that integrates JavaScript, DOM, CSS and Ajax, simplifying the JavaScript programming, promotion write less, do more.

2 difference, jQuery and JavaScript,

  • jQuery load faster than JavaScript, jQuery finished loading DOM rendering, JavaScript will be loaded all the elements on the page began to load
  • jQuery there is no coverage problems, restore order to perform a number of functions; there is coverage issues JavaScript, functions will be overwritten front, only the last execution

3, jQuery page load event

The following jQuery code execution will first pop-up page load event "page load event" and "the page has finished loading anonymous function", and then execute js method to bring up the "init () method."

When you click the button, it will pop up " Click the button to pop-up box 2"

 1 <!DOCTYPE html>
 2 <html>
 3     <head>
 4         <meta charset="utf-8" />
 5         <title>jQuery页面加载完毕事件</title>
 6         <script src="js/jquery-1.11.0.js"></script>
 7         <script src="demo.js"></script>
 8         <script>
 9             window.onload = function () {
 10                  document.getElementById ( " A " ) .onclick =  function () {Alert ( " click button pop-up box. 1 " )};
 . 11                  document.getElementById ( " A " ) .onclick =  function () {Alert ( " click the popup button 2 " )};
 12 is              }
 13 is          </ Script > 
14      </ head > 
15      < body the onload = "the init ()" > 
16          <button id="a">click</button>
17     </body>
18 </html>
. 1  function the init () {
 2      Alert ( "the init () method" )
 . 3  }
 . 4  
. 5  $ (Document) .ready (
 . 6      function () {
 . 7          Alert ( "page load event" );
 8      }
 9  )
 10  
. 11 $ ( function () {
 12 is      Alert ( "anonymous function page load" );
 13 })

 

Guess you like

Origin www.cnblogs.com/alphajuns/p/10994339.html