文章出處

在寫文章系統的刪除功能。需要刪除一行數據。在刪除的頁面,需要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()的時候,需要對他進行操作,我們要先得到 他的父級,然后在進行 操作。如上例。


文章列表


不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 大師兄 的頭像
    大師兄

    IT工程師數位筆記本

    大師兄 發表在 痞客邦 留言(0) 人氣()