1. jquery separates scripts from pages
In HTML Code We often see code similar to this:
<Form ID = "myform" onsubmit = return validate (); "> even if the validate () function can be placed in an external file, in fact, we are still mixing pages with logic and events. Jquery allows you to separate these two parts. With jquery, the page code is as follows:
<Form ID = "myform"> next, a separate JS file contains the following event submission code:
Copy code The Code is as follows: $ ("myform"). Submit (function (){
... Your code here
)}
In this way, we can implement clear Page code with high flexibility. Jquery separates JavaScript code from HTML page code, just as CSS separated style code from page code a few years ago.
2. Do the most with the least code
The least Code does the most. This is jquery's slogan and is truly worthy of the name. With its advanced selector, developers only need to write a few lines of code to achieve amazing results. Developers do not need to worry too much about browser differences. In addition to fully supporting Ajax, they also have many other abstract concepts that increase developers' programming efficiency. Jquery brings JavaScript to a higher level. The following is a simple example:
Copy code The Code is as follows: $ ("P. Neat"). addclass ("ohmy"). Show ("slow ");
With the short code above, developers can traverse all the <p> elements in the "neat" class, add the "ohmy" class to it, and slowly display each paragraph with an animation effect. Developers do not need to check the browser type of the client, do not need to write loop code, and do not need to write complex animation functions. The above results can be achieved through only one line of code.
3. Performance
In a large JavaScript framework, jquery has the best understanding of performance. Although there are many new features in different versions, the most simplified version is only 18 KB, which is hard to reduce. Each version of jquery has a significant performance improvement. This articleArticleIt is about jquery's original speed without any optimization. If you use it with a new generation of browsers with faster Javascript Engines (such as Firefox 3 and Google Chrome), developers will have a new speed advantage in creating rich web applications.
4. It is a "standard"
Quotes are used because jquery is not an official standard. However, jquery is widely supported in the industry. Google not only uses it but also provides it to users. In addition, Dell, news aggregation website Digg, WordPress, Mozilla and many other vendors are also using it. Microsoft even integrated it into Visual Studio. So many heavyweight manufacturers support this framework that users can rest assured of their future and boldly invest time in it.
5. Plug-ins
Jquery-based plug-ins already have thousands or so. Developers can use plug-ins to perform tasks such as Form validation, chart types, field prompts, animations, and progress bars. JqueryCommunityIt has grown into an ecosystem. This further proves the previous reason that it is a safe choice. In addition, jquery is actively cooperating with "competitors", such as prototype. They seem to be promoting the overall development of JavaScript, not just trying to gain one's own private.
6. Saving developer learning time
Of course, to really learn jquery, developers still need to spend a little time, especially if you want to write a lot of code or self-built plug-ins. However, developers can "break through each other", and jquery provides a lot of sample code. Getting Started is very easy. I suggest that developers first check whether there is a similar plug-in before writing a specific type of code, and then check the actual plug-in code to understand how it works. In short, to learn jquery, developers can quickly start development without having to invest too much, and then gradually improve their skills.
7. Make JavaScript programming interesting
I found that using jquery is a pleasure. It is concise and powerful, allowing developers to quickly get what they want. It solves many JavaScript problems and problems. I used to hate JavaScript programming, but now I like it very much. Through some basic improvements, developers can really think about developing the next generation of Web applications without worrying about poor languages or tools. I believe in its "the least code to do the most things.
Jquery's shortcomings
Of course, jquery is not perfect. The jquery shortcomings I have found so far include:
◆ Backward compatibility. Each new version is not compatible with earlier versions. For example, some new versions do not support some selectors, but jquery does not retain their support, but simply remove them. This may affect the code or plug-ins that have been compiled by developers.
◆ Plug-in compatibility. Similar to the previous version, when the new version of jquery is released, if developers want to upgrade it, it depends on whether the plug-in author supports it. In general, the current plug-in may not work properly in the latest jquery version. The more plug-ins developers use, the higher the chance of such a situation. I once had to manually modify a third-party plug-in to upgrade to jquery 1.3.
◆ When multiple plug-ins are used on the same page, conflicts are easily encountered, especially when these plug-ins depend on the same event or selector. Although this is not a problem of jquery itself, it is indeed a problem that is difficult to debug and solve.
◆ Jquery stability. It didn't crash my browser. I am referring to its version release policy. In just a few days after the release of jquery 1.3, a vulnerability correction Version 1.3.1 was released. They also removed support for some features, which may affect the normal operation of many codes. I hope that similar changes will not appear again.
◆ In large frameworks, jquery's core code library provides relatively poor support for animation and special effects. But in fact this is not a problem. There is a separate jquery UI project and many plug-ins to make up for this.
if you are still wondering whether to learn a javascript framework and are confused about which framework to choose, we recommend that you choose jquery. This does not mean that other frameworks are not good, but jquery may be the safest and most responsive choice.