删除可拖动对象jquery ui

时间:2012-02-26 11:01:46

标签: jquery jquery-ui

我有可拖动的对象,如何添加删除按钮来删除此对象?

2 个答案:

答案 0 :(得分:2)

只是一个例子:

$(<your draggable objects selector>).append('<div class="close">close</div>');
$('.close', <your draggable objects selector>).click(function() {
    $(this).parent().remove();
});

答案 1 :(得分:1)

假设一些HTML结构如下..

<div class="draggable-container">

    <div class="close">
    </div>

</div>

.draggable-container
{
    position:relative;
}

.close
{

    position:absolute;
    left:10px;
    top:10px;
    cursor:pointer;

}

$('.draggable-container .close').click(function(){
   //implement close here
   // eg: $(this).closest('.draggable-container').fadeOut();
});