Home  >  Article  >  Web Front-end  >  What are the advantages of jquery

What are the advantages of jquery

藏色散人
藏色散人Original
2023-03-25 10:57:563448browse

The advantages of jquery are: 1. Lightweight; 2. Powerful selector; 3. Excellent encapsulation of DOM operations; 4. Reliable event processing mechanism; 5. Perfect Ajax; 6. Pollution top-level variables; 7. Excellent browser compatibility; 8. Chain operation method; 9. Separation of behavior layer and structure layer; 10. Rich plug-in support; 11. Complete documentation; 12. Open source.

What are the advantages of jquery

The operating environment of this tutorial: Windows 10 system, jquery3.2.1, Dell G3 computer.

What are the advantages of jquery?

jQuery is a fast and concise JavaScript framework. It is another excellent JavaScript code library (framework) after Prototype. It was released by John Resig in January 2006. The purpose of jQuery's design is "write less, do more", which means writing less code and doing more things. It encapsulates common JavaScript function codes, provides a simple JavaScript design pattern, and optimizes HTML document operations, event processing, animation design and Ajax interaction.

The core features of jQuery can be summarized as follows: It has a unique chain syntax and a short and clear multi-functional interface; it has an efficient and flexible CSS selector, and can expand the CSS selector; it has convenient plug-in extensions Mechanism and rich plug-ins. jQuery is compatible with various mainstream browsers, such as IE 6.0, FF 1.5, Safari 2.0, Opera 9.0, etc.

Advantages of Jquery

(1) Lightweight. jQuery is very lightweight. After compression using Dean Edwards' Packer (http://dean.edwards.name/packer/), the size is less than 30KB. If gzip compression is enabled on the server, the size is even only 16KB!

(2) Powerful selector. jQuery allows operators to use almost all selectors from CSS 1 to CSS 3, as well as advanced and complex selectors unique to jQuery. If you need, you can also add a plug-in to support XPath selectors! In the next chapter, we will explain to you the powerful selectors in jQuery in detail.

(3) Excellent encapsulation of DOM operations. jQuery encapsulates a large number of commonly used DOM operations, allowing you to write programs related to DOM operations with ease, elegantly completing various otherwise very complex operations, and allowing JavaScript novices to write excellent programs. Chapter 3 will focus on introducing you to the elegant DOM operations in jQuery.

(4) Reliable event processing mechanism. jQuery's event processing mechanism absorbs the essence of the event processing function written by JavaScript expert Dean Edwards, making jQuery quite reliable when processing event binding. jQuery also does a very good job in reserving graceful degradation. Chapter 4 will focus on event handling in jQuery.

(5) Perfect Ajax. jQuery encapsulates all Ajax operations into a function $.ajax, allowing us to concentrate on business logic when dealing with Ajax without having to worry about complex browser compatibility and the creation and use of XMLHttpRequest objects. Chapter 6 will focus on Ajax processing in jQuery.

(6) Do not pollute top-level variables. jQuery only creates an object named jQuery, and all its methods are under this object. Another alias $ can also hand over control at any time. It will never contaminate other objects!

(7)Excellent browser compatibility. As a popular JavaScript library, browser compatibility is naturally one of the necessary conditions. jQuery can run normally under IE 6.0, FF 2, Safari 2.0 and Opera 9.0. Also fixed some differences between browsers. This saves you from having to worry about building a browser compatibility library before starting a project.

(8) Chain operation mode. The most distinctive feature of jQuery is its chain operation method - that is, a set of actions that occur on the same jQuery object can be written directly without repeatedly obtaining the object. This makes jQuery code extremely elegant. Please note that in Chapter 1.3.3, we will discuss the corresponding coding style issues.

(9) Separation of behavioral layer and structural layer. Developers no longer need to call events in html, but directly use jQuery selectors to select elements and then add events directly to the elements.

(10) Rich plug-in support. The growth of anything can never develop without the support of many people. jQuery's easy extensibility has attracted developers from all over the world to jointly write jQuery extension plug-ins. There are currently more than hundreds of official plug-ins supported. In Chapter 7, we will introduce several currently popular plug-ins and guide everyone to write their own plug-ins.

(11) Complete documentation. The documentation of jQuery is very rich. At present, most of the documentation is in English, but there are fewer Chinese documents. Of course, many teams that love jQuery are working hard on this, such as "Learning jQuery" translated by Turing Education.

(12) Open source. jQuery is an open source product that anyone can use freely.

jQuery language features

  • Quickly obtain document elements

jQuery’s selection mechanism is built on Css Selector, which provides the ability to quickly query elements in DOM documents, and greatly enhances the way to obtain page elements in JavaScript.

  • Provide beautiful page dynamic effects

jQuery has a series of built-in animation effects, which can develop very beautiful web pages. Many websites use jQuery’s built-in effects, such as fade in and fade out, element removal and other dynamic special effects.

  • Create AJAX non-refresh web pages

AJAX is the abbreviation of asynchronous JavaScript and XML, which can develop very sensitive non-refresh web pages, especially When developing server-side web pages, such as PHP websites, you need to communicate with the server back and forth. If you don't use AJAX, you have to refresh the web page every time the data is updated. With AJAX special effects, you can partially refresh the page to provide dynamic effects. .

  • Provides enhancements to the JavaScript language

jQuery provides enhancements to basic JavaScript structures, such as element iteration and array processing.

  • Enhanced event handling

jQuery provides various page events, which can avoid programmers from adding too much event handling code in HTML , and most importantly, its event handlers eliminate various browser compatibility issues.

  • Change the content of the web page

jQuery can modify the content of the web page, such as changing the text of the web page, inserting or flipping the web page image, jQuery simplifies The way JavaScript code needs to be handled originally.

Recommended learning: "jQuery Video Tutorial"

The above is the detailed content of What are the advantages of jquery. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn