jQuery插件检查版本 [英] jQuery Plugin Check Version

查看:90
本文介绍了jQuery插件检查版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编写新的jQuery插件时,有一种直接的方法可以检查当前版本的jQuery是否高于某个数字?否则显示警告或记录错误。

When writing a new jQuery plugin is there a straightforward way of checking that the current version of jQuery is above a certain number? Displaying a warning or logging an error otherwise.

这样做会很好:

jQuery.version >= 1.2.6

以某种形式或其他形式。

in some form or another.

推荐答案

这是我用来确保用户至少使用v.1.3.2的jQuery的检查。

Here is a check I used to make sure the user was using at least v. 1.3.2 of 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.
}

这篇关于jQuery插件检查版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆