jQuery Select2插件版本检查 [英] Jquery Select2 plugin version check
问题描述
在我的项目中,我检查是否以这种方式加载了Select2插件
In my project I check if the Select2 plugin was loaded in this way
if (jQuery().select2)
但是现在我将尝试验证加载了哪种版本的Select2插件(3.5.X或4.X).我想也许您可以检查是否存在版本4.X中引入的选项/功能,而该选项/功能在版本3.5.X中不存在. 根据您的说法,这可行吗?我该怎么办?谢谢
But now I will try to verify what kind of version (3.5.X or 4.X) of Select2 plugin was loaded. I thought maybe you could check if there is an option/function introduced in version 4.X that is not present in the version 3.5.X. According to you, is it doable? How might I do it? Thank you
推荐答案
Select2 4.0中有一个新的isOpen
方法.
There is a new isOpen
method in Select2 4.0.
您可以在开发人员工具栏中使用类似的内容:
You can use something like this in your developer toolbar:
try {
$("#a-select2-element").select2('isOpen');
'select2 v4.x';
} catch(e) {
'select2 v3.x';
}
经过Select2 v3.5.3和v4.0.3的测试
Tested with Select2 v3.5.3 and v4.0.3
这篇关于jQuery Select2插件版本检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!