Introduction to jQuery
What is jQuery
jQuery is a set of Javascript script libraries. We encapsulate some tool methods or object methods in class libraries to facilitate users to use.
Note that jQuery is a script library, not a script framework. "Library" is not equal to "framework". For example, "System Assembly" is a class library, and "ASP.NET MVC" is a framework. jQuery cannot help us solve the reference management of scripts. And function management, these are what the script framework has to do.
The script library can help us complete the coding logic and realize the business functions. Using jQuery will greatly improve the efficiency of writing JavaScript code, allowing the written The code is more elegant and robust. At the same time, the abundant jQuery plug-ins on the Internet have also made our work become "with jQuery, drink tea every day"-because we are already standing on the shoulders of giants.
jQuery is a lightweight "write less, do more" JavaScript library.
jQuery library includes the following functions:
HTML element selection
HTML element operation
CSS operation
HTML event function
JavaScript Special Effects and Animations
HTML DOM Traversal and Modification
AJAX
Utilities
jQuery has the following characteristics:
1. Provides powerful functional functions
Using these functional functions can help us quickly complete various functions, and will make our code extremely concise .
2. Solve browser compatibility issues
The compatibility of JavaScript scripts in different browsers has always been a nightmare for web developers. Often a page runs normally under IE7 and Firefox. Inexplicable problems occur under IE6. Writing different scripts for different browsers is a painful thing. With jQuery, we will wake up from this nightmare. For example, the Event event object in jQuery has been formatted for all browsers. Common to all browsers, in the past we had to get the event trigger based on the event, which is event.srcElements under IE and event.target under standard browsers such as FF. jQuery allows us to use events in all browsers by unifying the event object. .target gets the event object.
3. Implement rich UI
jQuery can achieve animation effects such as gradient pop-up, layer movement, etc., allowing us to obtain a better user experience. Using gradient alone Take the effect as an example. Once upon a time, I wrote a gradient animation that was compatible with IE and FF. I used a lot of JavaScript code to implement it. It took a lot of time and effort. After writing it, it didn't help much and I forgot about it after a while. I still want to develop similar functions again. We have to work hard again. Now using jQuery can help us quickly complete such applications.
4. Correcting wrong scripting knowledge
Most developers have wrong understanding of JavaScript. For example, writing statements in the page that are executed when loading to operate the DOM, directly on the HTML element or document object Add the "onclick" attribute, not knowing that onclick is actually an anonymous function, etc. Technical personnel with knowledge of these error scripts can also complete all development work, but such a program is not robust. For example, "when writing in the page when loading That is, "statements that operate the DOM" are executed. When the page code is small and the user loads it quickly, there is no problem. When the page loads a little slowly, the browser "terminates the operation" error will occur. jQuery provides many simple methods to help us solve the problem. These problems, once you use jQuery you will have the knowledge to correct these mistakes - because we are all using the standard correct jQuery scripting method!
Why use jQuery?
There are a large number of open source JS frameworks on the Internet, but jQuery is currently the most popular JS framework and provides a large number of extensions.
Many big companies are using jQuery, for example:
Microsoft
IBM
Netflix
Basic knowledge you need
Before you start learning jQuery, you should have a basic understanding of the following:
HTML
CSS
JavaScript
If you need to learn these subjects first, please find these tutorials on our Home Page .