如何获得jQuery-UI版本? [英] How do I get the jQuery-UI version?
问题描述
这应该是一个简单的问题,但是如何检测jQuery-UI版本?
This should be an easy question, but how do I detect the jQuery-UI version?
这是针对Greasemonkey脚本的,并且(当前)目标页面似乎正在运行jQuery-UI 1.5.2.但是,不同的目标页面可能运行不同的版本.
This is for a Greasemonkey script and the (current) target page appears to be running jQuery-UI, 1.5.2. But, different target pages may run different versions.
console.log ($.ui);
对于版本检测未显示任何有用/明显的内容.
console.log ($.ui);
did not show anything useful/obvious for version detection.
推荐答案
You can use $.ui.version
, it's actually the property jQuery UI looks for when determining if it should load itself (if it's already there, abort).
不幸的是,在jQuery-UI 1.6版中添加了$.ui.version
.
Unfortunately, $.ui.version
was added in jQuery-UI version 1.6.
对于早期版本,您可以检查$.ui
.
For earlier versions, you can check for $.ui
though.
因此,在这种情况下,以下内容可能就足够了:
So, in this case, the following might be good enough:
var version = $.ui ? $.ui.version || "pre 1.6" : 'jQuery-UI not detected';
这篇关于如何获得jQuery-UI版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!