如何删除jQuery中的小部件?

时间:2013-10-22 12:04:03

标签: jquery jquery-ui jquery-ui-sortable

我指的是jQuery widgets。我需要添加Cross X按钮来删除小部件。我怎么能这样做?

这是我的jsfiddle

1 个答案:

答案 0 :(得分:1)

使用destroy()方法,例如,

$( ".selector" ).sortable( "destroy" );

代码

$(document).on('click','.close',function(){
     $(this).closest('.column').sortable( "destroy" ).remove();// to destroy element
     //$(this).closest('.column').sortable( "destroy" );// to destroy widget only
});

Demo