jQuery source code analysis notes_PHP tutorial
The purpose of jQuery is Write Less, Do More. It's not as intrusive a JavaScript development style as YUI, and certainly not as massive as Dojo and YUI. It greatly simplifies the daily development work of JavaScript, mainly the operation of DOM elements (as can be seen from the name Query). Another major task that every front-end developer needs to face is browser compatibility. jQuery is compatible with most versions of all major browsers, starting from the evil IE6 to modern browsers such as Firefox and Chrome. Except for a small part of the core code, the rest of jQuery are loose functions and are highly extensible. There are thousands of jQuery plug-ins on http://plugins.jquery.com. Almost all the functions you need have corresponding jQuery plug-ins, and there is more than one.
The head of the jQuery code is the License statement. It adopts GPLv2 and MIT dual agreements. And under the jQuery declaration is the declaration of another project: Sizzle. This is another open source project from the author of jQuery, released under MIT, BSD and GPL. It is an independent selector implementation (pure-JavaScript CSS selector engine) and can be used independently. Its compressed version is only a little over 3KB and is known as the most efficient selector implementation. jQuery uses Sizzle instead of the original selector implementation starting from 1.3.
There are a lot of () and {} in the JS code. Vim is used to read it here, because the % command can quickly find matching brackets.
The overall code structure and variables
The jQuery code as a whole is an anonymous function call:
(function (window, undefined) {
// ...
})(window);
This is to avoid polluting the global object and is also convenient The management execution context. This technique is often seen in JS code and is also common in jQuery code. For example, when jQuery is used with other JS libraries, the $ symbol may have been used. To still use the $ sign:
(function ($) {
// $ ("...")... As usual use $
})(jQuery);
Pass in the real jQuery object here.
Let’s enter the real implementation part. The first is $, which is the declaration of the jQuery object. The two most basic members are also listed:
var jQuery = (function() {
var jQuery = function(selector, context) {
// The real initialization function
return new jQuery.fn.init(selector, context, rootjQuery);
},
// A lot of variable declarations
// fn is the main function implementation point and the starting point of the jQuery plug-in. JS prototype
jQuery.fn = jQuery.prototype = {
};
// A function used to extend an object, which can dynamically add members to the object. In the future, extend will be used to add members to jQuery. Function completed.
jQuery.extend = jQuery.fn.extend = function() {
};
// ...
return jQuery;
})();
The jQuery object is the core object. All $(...) obtains are jQuery objects. Except for a small number of Utility functions directly implemented under jQuery, most functions are added using the extend method. into the jQuery object.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











How to delete Xiaohongshu notes? Notes can be edited in the Xiaohongshu APP. Most users don’t know how to delete Xiaohongshu notes. Next, the editor brings users pictures and texts on how to delete Xiaohongshu notes. Tutorial, interested users come and take a look! Xiaohongshu usage tutorial How to delete Xiaohongshu notes 1. First open the Xiaohongshu APP and enter the main page, select [Me] in the lower right corner to enter the special area; 2. Then in the My area, click on the note page shown in the picture below , select the note you want to delete; 3. Enter the note page, click [three dots] in the upper right corner; 4. Finally, the function bar will expand at the bottom, click [Delete] to complete.

As a Xiaohongshu user, we have all encountered the situation where published notes suddenly disappeared, which is undoubtedly confusing and worrying. In this case, what should we do? This article will focus on the topic of "What to do if the notes published by Xiaohongshu are missing" and give you a detailed answer. 1. What should I do if the notes published by Xiaohongshu are missing? First, don't panic. If you find that your notes are missing, staying calm is key and don't panic. This may be caused by platform system failure or operational errors. Checking release records is easy. Just open the Xiaohongshu App and click "Me" → "Publish" → "All Publications" to view your own publishing records. Here you can easily find previously published notes. 3.Repost. If found

How to add product links in notes in Xiaohongshu? In the Xiaohongshu app, users can not only browse various contents but also shop, so there is a lot of content about shopping recommendations and good product sharing in this app. If If you are an expert on this app, you can also share some shopping experiences, find merchants for cooperation, add links in notes, etc. Many people are willing to use this app for shopping, because it is not only convenient, but also has many Experts will make some recommendations. You can browse interesting content and see if there are any clothing products that suit you. Let’s take a look at how to add product links to notes! How to add product links to Xiaohongshu Notes Open the app on the desktop of your mobile phone. Click on the app homepage

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

How to display the source code of PHP code in the browser without being interpreted and executed? PHP is a server-side scripting language commonly used to develop dynamic web pages. When a PHP file is requested on the server, the server interprets and executes the PHP code in it and sends the final HTML content to the browser for display. However, sometimes we want to display the source code of the PHP file directly in the browser instead of being executed. This article will introduce how to display the source code of PHP code in the browser without being interpreted and executed. In PHP, you can use

Title: Analysis of the reasons and solutions for why the secondary directory of DreamWeaver CMS cannot be opened. Dreamweaver CMS (DedeCMS) is a powerful open source content management system that is widely used in the construction of various websites. However, sometimes during the process of building a website, you may encounter a situation where the secondary directory cannot be opened, which brings trouble to the normal operation of the website. In this article, we will analyze the possible reasons why the secondary directory cannot be opened and provide specific code examples to solve this problem. 1. Possible cause analysis: Pseudo-static rule configuration problem: during use

Title: Is Tencent’s main programming language Go: An in-depth analysis. As China’s leading technology company, Tencent has always attracted much attention in its choice of programming languages. In recent years, some people believe that Tencent mainly adopts Go as its main programming language. This article will conduct an in-depth analysis of whether Tencent's main programming language is Go, and give specific code examples to support this view. 1. Application of Go language in Tencent Go is an open source programming language developed by Google. Its efficiency, concurrency and simplicity are loved by many developers.
