admin管理员组文章数量:1129047
Is there a way to find out what version of jQuery is being used by inspecting the jQuery
object? jQuery is dynamically getting added to my page and I cannot see any reference to it in my markup. If I inspect it in my browser's console, it's there.
Is there a way to find out what version of jQuery is being used by inspecting the jQuery
object? jQuery is dynamically getting added to my page and I cannot see any reference to it in my markup. If I inspect it in my browser's console, it's there.
7 Answers
Reset to default 560You can use either $().jquery;
or $.fn.jquery
which will return a string containing the version number, e.g. 1.6.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.
For instance, jQuery.fn.jquery
or jQuery().jquery
would work just fine:
$().jquery
will give you its version as a string.
For older versions of jQuery
jQuery().jquery (or)
jQuery().fn.jquery
For newer versions of jQuery
$().jquery (or)
$().fn.jquery
$()['jquery']
Invoke console.log($())
and take note about jquery object fields :
- jquery
- selector
- prevObject
You can get the version of the jquery by simply printing object.jquery
, the object
can be any object created by you using $
.
For example: if you have created a <div>
element as following
var divObj = $("div");
then by printing divObj.jquery
will show you the version like 1.7.1
Basically divObj
inherits all the property of $()
or jQuery()
i.e if you try to print jQuery.fn.jquery
will also print the same version like 1.7.1
console.log( 'You are running jQuery version: ' + $.fn.jquery );
本文标签: javascriptGet jQuery version from inspecting the jQuery objectStack Overflow
版权声明:本文标题:javascript - Get jQuery version from inspecting the jQuery object - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736719640a1949396.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论