This is some text that analyzes the jquery framework
For jquery 1.3.2 version
Readers should have the following requirements
1. Very familiar with HTML
2. Very familiar with JavaScript grammar knowledge
3. Familiarity with JavaScript-oriented object-oriented knowledge
4. Proficiency in using the jquery framework
Anyway
The initialization of a jquery object is written in an anonymous function.
Just like this:
(function(){alert("jQuery框架分析")})();
The first bracket is the declaration of a function, and the second parenthesis is the execution of this function. That is, the jquery framework has done something when the page was loaded (this anonymous function has been executed). These things are done so that we can get the page elements through $ ("#yourId") or $ (". YourClass"), and wrap the acquired elements into jquery objects.
How does an anonymous function implement these functions?
First, the framework defines two core objects
jQuery = window.jQuery = window.$ = function( selector, context ) {}
One is jquery.
One is $
Both of these objects point to a function
This function is the entry that we use for the $ () or jquery () method, which returns an instance of JQuery.fn.init (selector, context), in fact this instance is a jquery object.
What kind of object is a jquery object?
The jquery object is actually an array of javascript
This array object contains 125 methods and 4 properties