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

前端 未结 5 1776
轻奢々
轻奢々 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:40

    All ui widgets attach their name as true to the element's container data. jqueryui also adds a data filter expression.

    var $elem = $('div.sortable-container:data(sortable)');
    if ($elem.length){
      // $elem contains list of elements that have sortable widget attached
    }
    

提交回复
热议问题