jQuery 1.2 带来的兼容问题及对策
jQuery 1.2 中拋棄了不少之前的功能,因此不能向前兼容,而有不少非官方的 jQuery 插件(比如 thickbox),使用的是 jQuery 1.2 之前的語法開發的,如果這次還未根據新版本更新的,則可能會出現問題。下面是一些新的寫法,主要是關于選擇器 (Selector) 的語法方面:
$("div//p") XPath Descendant Selector
Please use the CSS $("div p") selector instead. Or, use the XPath Compatibility Plugin.
$("div/p") XPath Child Selector
Please use the CSS $("div > p") selector instead. Or, use the XPath Compatibility Plugin.
$("p/../div") XPath Parent Selector
Please use the $("p").parent("div") selector instead. Or, use the XPath Compatibility Plugin.
$("div[p]") XPath Contains Predicate Selector
Please use the new $("div:has(p)") selector instead. Or, use the XPath Compatibility Plugin.
$("a[@href]") XPath Attribute Selector
Note: While this selector is deprecated, it has not yet been removed as of this release (jQuery 1.2).
It is now recommended that you use the CSS selector $("a[href]") instead. Or, use the XPath Compatibility Plugin.
另有一個 jquery.xpath.js 的插件做向前兼容,但我測試下來好像不理想,有很多會不生效。
現在比較好的做法是修改老代碼中使用到 XPath Selector 的語法為 CSS Selector.
全部的更改列表需要仔細閱讀 jQuery 1.2 的發布說明:
http://docs.jquery.com/Release:jQuery_1.2
這里只是我對比較重要的方面的一個摘錄。
另外不能理解的就是 jQuery 為什么要把 XPath Selector 的功能分離出去。。。
轉載于:https://www.cnblogs.com/RChen/archive/2007/09/27/908354.html
總結
以上是生活随笔為你收集整理的jQuery 1.2 带来的兼容问题及对策的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Resin-IOException: w
- 下一篇: 海信65E3D–J和海信VIDAA 65