jQuery Plugin Check Version

前端 未结 15 919
轮回少年
轮回少年 2020-12-16 11:57

When writing a new jQuery plugin is there a straightforward way of checking that the current version of jQuery is above a certain number? Displaying a warning or logging an

15条回答
  •  暖寄归人
    2020-12-16 12:08

    What about:

    function minVersion(version) {
    var $vrs = window.jQuery.fn.jquery.split('.'),
    min  = version.split('.'),
    prevs=[];
    
    for (var i=0, len=$vrs.length; i min[i])
                prevs[i] = 1;
            else
                prevs[i] = 0;
        }
    }
    return true;
    

    }

    I wrote that code on my forked gist: https://gist.github.com/budiadiono/7954617, original code written by dshaw on: https://gist.github.com/dshaw/652870.

提交回复
热议问题