当编写一个新的jQuery插件时,有没有一种直接的方法来检查jQuery的当前版本是否超过一定数量?显示警告或记录错误。
做这样的事情会很好:
jQuery.version >= 1.2.6
以某种形式出现。
最佳答案
这是我用来确保用户至少使用1.3.2版jQuery的检查。
if (/1\.(0|1|2|3)\.(0|1)/.test($.fn.jquery)
|| /^1.1/.test($.fn.jquery)
|| /^1.2/.test($.fn.jquery))
{
//Tell user they need to upgrade.
}