1
我有可拖動的對象,如何添加刪除按鈕以刪除此對象?刪除可拖動的對象jquery ui
我有可拖動的對象,如何添加刪除按鈕以刪除此對象?刪除可拖動的對象jquery ui
假設一些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();
});
只是一個例子:
$(<your draggable objects selector>).append('<div class="close">close</div>');
$('.close', <your draggable objects selector>).click(function() {
$(this).parent().remove();
});