如何检查是否加载了jQuery UI小部件?

Ste*_*ing 5 jquery jquery-ui

我知道我可以检查是否jQuery UI的核心加载jQuery.ui,但如何检查,如果一个widget( draggable)被加载时,我使用的typeof($('something').draggable) == 'function',是没有更好的办法来做到这一点?

小智 7

你可以尝试这样:

if (typeof(jQuery.ui.draggable) != 'undefined'){
    // UI draggable is loaded
}
Run Code Online (Sandbox Code Playgroud)