文章出處
文章列表
在寫文章系統的刪除功能。需要刪除一行數據。在刪除的頁面,需要jQuery 刪除一hang. 局部刷新數據。
$(".del").click(function(){ var id = $(this).attr("hid"); var t = $(this).parent().parent(); var i = confirm("是否確認刪除"); if(i){ $.post("<?php echo $this->createUrl('del');?>",{id:id},function(m){ if(m==1){ //console.log(id); // window.location.reload(); // $(this).parent().parent().remove(); 是沒有作用的。 t.remove(); }else{ alert("刪除失敗"); } }); }else{ //alert("刪除失敗"); } });
在使用 $(this).parent()的時候,需要對他進行操作,我們要先得到 他的父級,然后在進行 操作。如上例。
文章列表
全站熱搜