Get jQuery version from inspecting the jQuery object

后端 未结 7 1891
小蘑菇
小蘑菇 2020-12-02 04:26

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

相关标签:
7条回答
  • 2020-12-02 04:36
    console.log( 'You are running jQuery version: ' + $.fn.jquery );
    
    0 讨论(0)
  • 2020-12-02 04:40

    You can use either $().jquery; or $.fn.jquery which will return a string containing the version number, e.g. 1.6.2.

    0 讨论(0)
  • 2020-12-02 04:44

    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:

    screen shot for checking jQuery version

    0 讨论(0)
  • 2020-12-02 04:49
    $()['jquery']
    

    Invoke console.log($()) and take note about jquery object fields :

    • jquery
    • selector
    • prevObject

    enter image description here

    0 讨论(0)
  • 2020-12-02 04:51

    $().jquery will give you its version as a string.

    0 讨论(0)
  • 2020-12-02 04:51

    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

    0 讨论(0)
提交回复
热议问题