jQuery Plugin Check Version

前端 未结 15 908
轮回少年
轮回少年 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:17

    If it's enough to check minor version, not patch version, you can do something like

    parseFloat(jQuery.fn.jquery) >= 1.9

    It is possible to change this slightly to check >= 1.4.3: parseFloat(jQuery.fn.jquery) > 1.4 || parseFloat(jQuery.fn.jQuery) == 1.4 && parseFloat(jQuery.fn.jQuery.slice(2)) >= 4.3

提交回复
热议问题