2013-04-12 175 views
0

有人可以告訴我如何使用jquery刪除和隱藏事件嗎?其實目前我使用的jquery波紋管及其工作正常,但它只是消除事件,但不隱藏它,請你可以修改它嗎?如何使用jquery刪除和隱藏?

function delData(id){ 
    if(confirm('Do you really want to delete it ? if yes then click OK and wait for next notification please.. ')){ 
     $.ajax({ 
      type:'POST', 
      url:'manage_reports.php?action=del&id='+id, 
      success:function(result){ 
       alert('Sale has been deleted successfully.. Do not refresh your page if you want to keep stay here'); 
       $(control).parents('table').eq(0).remove().hide("table"); 
      } 
     });  
    } 
}; 

謝謝你這麼多

回答

1

不能hide已刪除的項目只使用hideremove,如果你想刪除一些其他的元素,則單獨做到這一點。 hide不採用您可能要傳遞的選擇器,它需要一個參數,但其選項不是選擇器。

function delData(id){ 
    if(confirm('Do you really want to delete it ? if yes then click OK and wait for next notification please.. ')){ 
     $.ajax({ 
       type:'POST', 
       url:'manage_reports.php?action=del&id='+id, 
       success:function(result){ 
        alert('Sale has been deleted successfully.. Do not refresh your page if you want to keep stay here'); 
        $(control).parents('table').eq(0).remove(); 
      }}); 
}}; 
+0

'.hide()'不會將選擇器作爲參數。你不想''.hide()'而不是'.hide(「table」)'? –

+0

謝謝@JeffB,很高興你更新了我的答案。 – Adil

+0

對不起,它不適用於我:( –

0

如果說「刪除事件」你的意思是讓一個事件,如「鼠標點擊」無效,那麼我建議你先創建/使用綁定綁定該事件或生活的元素

一旦你的ajax請求完成刪除/隱藏元素,並調用一個.unBind('事件')。