我做了一個簡單的FileManager,但我不知道我的代碼有什麼問題,我用了幾次remove()
和/或detach()
函數的jQuery,但這次是從網格的其餘部分刪除選定的節點。代碼如下:jquery刪除()不按預期方式工作
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script>
$(document).ready(function(){
$(".excluir").click(function(){
$(this).remove();
});
$("#novo").click(function(){
$("#gradearquivos").append("<div class=\"miniatura\"><button class=\"excluir\">X</button></div>");
});
});
</script>
的append()
工作正常,創建文件大拇指,但remove()
是不是! 這次我做錯了什麼? PS:jsFiddle 謝謝先進!
是否則,你可能只是重新進行綁定。 – clancer
@clancer:在這種情況下,每次都需要綁定事件,我認爲這是最好的方式 –
非常感謝,現在我明白了! –