I'm trying to check if the current jquery version is greater than 1.8.3 but parseInt($.fn.jquery) only outputs one digit.
Not sure it's the most efficient but seems to work... Take the version string, split it into tokens and test each token, like below
var vernums = $.fn.jquery.split('.');
if (parseInt(vernums[0]) > 0 && parseInt(vernums[1]) >= 8 && parseInt(vernums[2]) > 3) {
// Do stuff here
}
Here's a simplistic "one liner" approach. I pad out the digits with leading zeros.:
if(jQuery.fn.jquery.split('.')
.map(function(i){return('0'+i).slice(-2)})
.join('.') > '01.08.03')
{
alert('yes');
}
else
{
alert('no');
}
I'm trying to check if the current jquery version is greater than 1.8.3 but parseInt($.fn.jquery) only outputs one digit.
Not sure it's the most efficient but seems to work... Take the version string, split it into tokens and test each token, like below
var vernums = $.fn.jquery.split('.');
if (parseInt(vernums[0]) > 0 && parseInt(vernums[1]) >= 8 && parseInt(vernums[2]) > 3) {
// Do stuff here
}
Here's a simplistic "one liner" approach. I pad out the digits with leading zeros.:
if(jQuery.fn.jquery.split('.')
.map(function(i){return('0'+i).slice(-2)})
.join('.') > '01.08.03')
{
alert('yes');
}
else
{
alert('no');
}
0 commentaires:
Enregistrer un commentaire