How to check if a jQuery UI plugin is attached to an element?

前端 未结 5 1772
轻奢々
轻奢々 2020-12-30 07:56

How can I check to see if a jQuery UI plugin is attached to an element? For example, if I load up the .sortable widget, how can its presence be determined?

The purpo

5条回答
  •  离开以前
    2020-12-30 08:33

    Since jQuery UI 1.8, special selectors are being added to Sizzle for each widget. These are in the form of :ui-widgetname.

    To check for the presence of a sortable widget on an element, you can therefore use:

    if(element.is(':ui-sortable')) {
        element.sortable('destroy');
    }
    

提交回复
热议问题