<div class="add">Click me to add new item to list</div>
<ul id="sortable">
<li class="delete">
<div class="item">these old items can be removed by click on <span class="delBtn">DEL</span></div>
</li>
<li class="delete">
<div class="item">these old items can be removed by click on <span class="delBtn">DEL</span></div>
</li>
<li class="delete">
<div class="item">these old items can be removed by click on <span class="delBtn">DEL</span></div>
</li>
</ul>
$("#sortable").sortable();
$(".add").click(function() {
var newItem = '<li class="delete"><div class="item">these <span class="red">new items cannot be removed</span> by click on <span class="delBtn">DEL</span></div></li>';
$("#sortable").append(newItem);
});
$("#sortable").delegate('.delBtn', 'click', function() {
alert("A click happened, it was captured at #commonParent and this alert ran");
});
,而不是警告新加入的項目,我woud想刪除列表項... 請幫幫我,我該怎麼做?無法刪除從一個jQuery排序列表2.0
可以try it here ...
THX!這是worx ...(我以前曾嘗試過......但顯然我做了錯誤的事情......現在它正在工作!) – Ruky