我有可拖动的对象,如何添加删除按钮来删除此对象?
答案 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();
});