jQuery版本检查

时间:2019-04-17 07:30:32

标签: jquery

我正在尝试检查jquery版本检查。在控制台中尝试了以下命令:

  1. jQuery。 fn。 jQuery
  2. jQuery()。 jQuery

,但两者都打印为“ jquery”而不是版本号。请帮我。 这个问题可能是重复的,但没有一个对我有用。因此,再次发布。

5 个答案:

答案 0 :(得分:1)

您可以使用$()。jquery;或$ .fn.jquery,它将返回包含版本号的字符串,例如1.6.2

调用console.log($())并注意有关jquery对象的字段

console.log('您正在运行jQuery版本:'+ $ .fn.jquery)

答案 1 :(得分:1)

$().jquery将以字符串形式提供其版本。

对于旧版jQuery

jQuery().jquery  
jQuery().fn.jquery

对于jQuery的较新版本

$().jquery
$().fn.jquery

答案 2 :(得分:0)

$().jquery将以字符串形式提供其版本。

链接source

sourse 2

对于旧版jQuery

jQuery().jquery  
jQuery().fn.jquery

对于jQuery的较新版本

$().jquery
$().fn.jquery

答案 3 :(得分:0)

在chrome开发工具的控制台中使用此行代码

$。fn.jquery

这以字符串形式提供jQuery版本

答案 4 :(得分:0)

if (typeof jQuery != 'undefined') {  
    // jQuery is loaded => print the version
    alert(jQuery.fn.jquery);
}

对我有用,试试吧