Events (eight) jQuery in

1. ready (fn), bind a function to be executed when the DOM is ready to query and manipulate

This method is an alternative to purely window.load event to register with the event. By using this method, the DOM is ready to be read in and call the function you are bound to immediately manipulate, and 99.99% of the JavaScript code needs to run at that moment.

Code that runs when the DOM is loaded, you can write

$ (the Document) .ready ( function () {
   // here to write your code ... 
});

Use $ (document) .ready () shorthand, while still inside the jQuery code using $ as an alias, regardless of the global $ why.

$ ( Function ($) {
   // You can continue to use $ as an alias here ... 
});

2. on (events, [selector], [data], fn), or select the elements to bind a plurality of event handler events

 

Guess you like

Origin www.cnblogs.com/myitnews/p/11784938.html