How to know which version of jquery was loaded

7

The code below perfectly shows me whether jQuery was uploaded:

if (jQuery) {
    $('div#home_login').attr('style', 'background: green');
} else {
    $('div#home_login').attr('style', 'background: red'); }

But how do I know which version was loaded, or versions, because I have some plugins that do not work with certain versions, such as autocomplete and .on that do not work with the same version.

I wanted to know when the version or versions were uploaded.

    
asked by anonymous 29.03.2016 / 16:14

1 answer

4

Use the $.fn.jquery command to get a string with the version. Note in the example that the version that will be loaded into the project will always be the last one, it will never load more than one version at a time.

var versaoJquery = $.fn.jquery;
console.log('Versão jQuery: ' + versaoJquery);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>

Source: jQuery API

    
29.03.2016 / 16:17