从检查jQuery对象获取jQuery版本

本文翻译自:Get jQuery version from inspecting the jQuery object

Is there a way to find out what version of jQuery is being used by inspecting the jQuery object? 有没有办法通过检查jQuery对象找出正在使用的jQuery版本? jQuery is dynamically getting added to my page and I cannot see any reference to it in my markup. jQuery动态地添加到我的页面,我在我的标记中看不到任何对它的引用。 If I inspect it in my browser's console, it's there. 如果我在浏览器的控制台中检查它,它就在那里。


#1楼

参考:https://stackoom.com/question/SoQi/从检查jQuery对象获取jQuery版本


#2楼

FYI, for the cases where your page is loading with other javascript libraries like mootools that are conflicting with the $ symbol, you can use jQuery instead. 仅供参考,对于您的页面加载其他javascript库(例如与$符号冲突的mootools)的情况,您可以使用jQuery代替。

For instance, jQuery.fn.jquery or jQuery().jquery would work just fine: 例如, jQuery.fn.jqueryjQuery().jquery可以正常工作:

用于检查jQuery版本的屏幕截图


#3楼

$()['jquery']

Invoke console.log($()) and take note about jquery object fields : 调用console.log($())并记下jquery对象字段:

  • jquery jQuery的
  • selector 选择
  • prevObject prevObject

在此输入图像描述


#4楼

console.log( 'You are running jQuery version: ' + $.fn.jquery );

#5楼

For older versions of jQuery 对于旧版本的jQuery

jQuery().jquery  (or)

jQuery().fn.jquery

For newer versions of jQuery 对于较新版本的jQuery

$().jquery  (or)

$().fn.jquery

#6楼

You can use either $().jquery; 你可以使用$().jquery; or $.fn.jquery which will return a string containing the version number, eg 1.6.2 . $.fn.jquery将返回包含版本号的字符串,例如1.6.2

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值