我有一个列表项,里面有一个按钮。该按钮被附加到一个jquery函数来删除列表项。jquery删除。在div内的按钮被删除
//Delete Button - delete from cart
$('.ui-icon-trash').click(function() {
$(this).closest('li').remove()
});
<li>
content here....
<a href="#" title="Remove from cart" class="ui-icon ui-icon-trash">Remove from cart</a>
</li>
为什么不工作?是否因为按钮位于我想要移除的项目内?有没有解决的办法??