Difference: 1. 2.x will no longer be updated. The official only does bug maintenance and no new functions will be added. 3.x is the official version that is mainly updated and maintained, and functions will continue to be added. 2. 3.x supports "for...of" loop statement, 2.x does not support ". 3. 2.x uses setInterval to implement animation, and 3.x uses requestAnimationFrame() to implement animation. 4. 3. width() and height() in .6.1 version, Dell G3 computer.
jQuery
Since its birth in
2006, a release## There are three major versions: #1.x, 2.x, 3.x . Under these three major versions, many smaller versions are subdivided. Version. Some friends may not know the difference between these versions. Which version should be used in actual development? Let me summarize it below. 1. 1.x, 2.x, Differences between the three major 3.x series1, Comparison of IE support
,
ie7ie7, ie8##2.X It is not compatible with ie678 and is rarely used by people. The official only does bug maintenance and no new functions will be added. If you do not consider compatibility with lower version browsers, you can use 2.x. Final version: 2.2.4 (May 20, 2016) 3.X is not compatible with ie678 and only supports the latest browsers. Unless there are special requirements, version 3.x is generally not used. Many old jQuery plug-ins do not support this version. Currently this version is the official main Update the maintained version. (2) Select the suggestion
ie678
: you can only choose1.x
If you do not need to be compatible with
jQuery
does not add any new features, mainly removes the support of ie678 , improves performance, and reduces physical examination. (2)3.x Compared with the previous version, many new features have been added and some previous features have also been changed.
2. Specific version suggestions1, version history
Latest update | Size (KB)
|
Remarks | ##1.0 |
August 26, 2006 |
First stable version |
1.1 |
##January 14, 2007 | ||
##1.2 |
September 10, 2007 |
##1.2.6 |
||
54 | #1.3 | January 14, 2009 | ##1.3.2||
will Sizzle |
Selector engine introduced into the core |
1.4 | 2010 1 Month 14 |
##1.4.4 76 |
##1.5 | January 31, 2011 | ##1.5.283 | ||
Module rewriting |
||||
##1.6 | May 3, 2011 | ##1.6.489 | Significant improvement between | attr() and val()Performance |
##November 3, 2011 |
1.7.2 (March 21, 2012) |
92 |
New events API | : .on() and .off(), while the old API is still supported. | 1.8
August 9, 2012 |
1.8 .3 (November 13, 2012) |
91.4 |
Rewrite Sizzle |
Selector engine, improved animation and $(html, props) flexibility. | 1.9
January 15, 2013 |
1.9 .1 (February 4, 2013) |
90 |
Remove deprecated interfaces and clean up code |
1.10 |
May 24, 2013 |
1.10.2 (July 2013 3rd) |
91 |
Fixed |
1.9 and 2.0 beta Version cycle bugs and differences ## 1.11 |
January 24, 2014 | ##1.11.3 (April 28, 2015)95.9 | 1.12 |
||
1.12.4 (May 20, 2016) | 95 | 2.0 |
||
2.0.3 (2013 July 3, 2018) | 81.1 | Remove support for | IE 6-8 to improve performance, and Reduce file size |
##2.1 |
2.1.4 (April 28, 2015) | 82.4 | ##2.2 | ||
##2.2.4 (May 20, 2016) | 85.6 | ##3.0 | 2016 June 9 |
|
##86.3 | Deferred, $.ajax, $.when support Promises/A, making .data() compatible with HTML5 | ##3.1 | July 7, 2016 | ##3.1.1 (September 23, 2016) |
86.3 | Join
| jQuery.readyException, ready handler | Errors will no longer be displayed | 3.2March 16, 2017##3.2.1 (2017 March 20, 2018) |
Added support for retrieving the content of the | element, Various old methods have been deprecated. |
3.3 | January 19, 2018 | 3.3 .1 (January 20, 2018) |
Deprecated the old function, the function can now accept classes, and supports writing them as Array format. |
2, 1.x commonly used version
3, 2.x, 3.x versionsUnless there are special requirements (such as for mobile terminals), these two versions are generally used There are indeed very few people:
##3. Summary of new features of jQuery3Different fromjQuery 2, the main thing is to improve performance. jQuery 3 actually adds many new features. I will summarize these new features in this article. (1) New features 1, support for...of loop statement Infor to loop through all input elements on the page, And modify its ID, you can write it like this: loop to write like this: The value obtained each time in the loop body is not a jQuery object, but A DOM element. This is similar to the .each() method provided by jQuery . (1) jQuery 3Added new parameter types for the two methods $.get() and $.post() #[settings], so that they are consistent with the interface style of $.ajax(). The only difference between //过去这么写 $.post('test.php', { name: 'hangge', age: 2 }, function (data) { console.log(data); }); // jQuery3 中可以这样写 $.post({ url: 'test.php', data: { name: 'hangge', age: 2 }, success: function (data) { console.log(data); } }); Copy after login $.get() and $.post() The [settings] passes the method attribute, the method attribute is passed value will be ignored. $.get({ url: 'test.php', method: 'POST' //这个将被忽略,仍然是get请求 }); Copy after login In previous versions, jQueryusedrequestAnimationFrame . requestAnimationFrame will continuously optimize the animation according to the browser's drawing time to make the animation smooth and reduce the consumption of CPU resources. (2) And jQuery 3 will use this API (1) We know to use unwrap() Method can delete the parent element of the selected element. (2)jQuery 3 为 unwrap() 方法增加了一个可选参数 selector,我们可以通过这个字符串选择器匹配元素的父元素: (1)过去想要通过 addClass()、removeClass()、toggleClass() 方法一次性设置多个类时,需要使用空格分开多个 class。 (2)而从 jQuery 3.3 起,这些方法可以直接接受类数组。 (1)jQuery 3 新增的 $.escapeSelector() 函数可以用来转义 CSS 选择器中有特殊意义的字符或字符串。此方法对于一个 CSS 类名或一个 ID 包含的字符在 CSS 中具有特殊含义的情况下非常有用,如点或分号。 (2)下面是一个简单的样例: (二)、有变更的特性 1,:visible 和 :hidden 过滤器含义变更 (1)jQuery 3 修改了 :visible 和 :hidden 过滤器的定义。任何可用于布局的元素 即使它们的高度宽度为 0,都会被认为是 :visible。 (2)比如 2,data() 方法 (1)现在 data() 方法行为已经变得跟 Dataset API 规范一致。jQuery 3 将会把所有属性键名转换成驼峰形式。 (2)比如下面一个样例: 3,Deferred 对象 Deferred 对象可以说是 Promise 对象的前身之一,它实现了对 Promise/A+ 协议 的兼容。关于 Deferred 更详细的用法可以参考我之前写的这篇文章: (1)jQuery 3 改变了 deferred 对象的行为,使得 deferred 对象可与新的 Promises/A+ 标准兼容。deferred 对象成为了可链对象,让创建回调队列成为可能。 (2)下面是一个简单的样例: 4,类操作方法支持 SVG (1)可惜的是,jQuery 现在还无法完全支持 SVG(包括 jQuery3)。 (2)但是在 jQuery 3 中,对于操作 CSS 类名称的 jQuery 方法,如 addClass() 和 hasClass() 现在可以将 SVG 文档作为目标。这意味着,我们可以修改(添加、移除、切换),或是寻找 SVG 下的 jQuery 类,然后使用 CSS 的样式。 废弃与移除的区别: (1)在很早之前,bind()、delegate()、unbind() 和 undelegate() 就已经不再推荐使用了,但它们还是一直存在着: (2)jQuery 3 终于开始将这些方法标记为 “废弃” 了,并计划在未来的某个版本(很可能是 jQuery 4)中将它们彻底移除。因此,建议我们在项目中统一使用 on() 和 off() 方法,这样就不用担心未来版本的变更了。 load()、unload() 和 error() 等方法在很早以前(从 jQuery 1.8 开始)就已经被标记为废弃了,但一直没有去掉。这次 jQuery 3 彻底将它们移除了。 jQuery3 移除了已经废弃的 context、support 和 selector 属性。 四、修复了之前版本中存在的重大 Bug 1,width() 和 height() 的返回值将不再取整 (1)在 jQuery 3 中,width() 和 height() 及所有其它相关方法将不再将结果的像素值四舍五入到一个整数值,因为四舍五入后在某些情况下很难对元素进行定位。 (2)比如下面样例,container 容器内有三个子元素,它们宽度均为父容器的 1/3。我们通过 width() 得到具体的宽度值: 2,wrapAll() 方法 (1)jQuery 3 Also fixed a bug in the wrapAll() method, this bug Appears when a function is passed to it as a parameter. In versions prior to jQuery 3, when a function was passed to the wrapAll() method, it would jQuery Each element of is wrapped individually. In other words, the behavior is exactly the same as when passing a function to wrap() . (2) While fixing this problem, another change was also introduced: Since in jQuery 3 , this function only It will be called once, then you cannot pass it every element in the jQuery collection. Therefore, the execution context of this function (this) will only point to the first element in the current jQuery collection. [Recommended learning: jQuery video tutorial, web front-end video] |
The above is the detailed content of What is the difference between jquery version 2.x and 3.x. For more information, please follow other related articles on the PHP Chinese website!