Testing if jQueryUI has loaded

前端 未结 5 1334
误落风尘
误落风尘 2020-11-29 23:22

I\'m trying to debug a website, and I think that jQueryUI may not have loaded properly. How can I test if jQueryUI has loaded?

5条回答
  •  日久生厌
    2020-11-30 00:01

    You can check if jQuery UI is loaded or not by many ways such as:

    if (typeof jQuery.ui == 'undefined') {
       // jQuery UI IS NOT loaded, do stuff here.
    }
    

    OR

    if (typeof jQuery.ui != 'function') {
        // jQuery UI IS NOT loaded, do stuff here.
    }
    

    OR

    if (jQuery.ui) {
        // This will throw an error in STRICT MODE if jQuery UI is not loaded, so don't use if using strict mode
        alert("jquery UI is loaded");
    } else {
        alert("Not loaded");
    }
    


提交回复
热议问题