2013-04-24 56 views
0
$("#my").click(function() { 
    $(this.title).remove(); 
}); 

我已經使用jQuery動態地添加和刪除html內容,但是如何刪除哪些創建動態添加。如何刪除使用jQuery動態創建的類

+0

請澄清「但是如何刪除動態添加的哪個創建。」,你需要從$(「#my」)中刪除一個類嗎? – 2013-04-24 05:36:10

回答

-1

只是嘗試

$("#my").live('click',function() 
{ 
$(this.title).remove(); 
} 
) 
+0

'live'方法已被棄用。 – undefined 2013-04-24 05:26:53

+0

沒有它的工作....謝謝 – 2013-04-24 05:37:09

+0

@ R.K http://api.jquery.com/live/ – undefined 2013-04-24 05:41:16

3

事件代表團使用了動態添加元素

試試這個

$(document).on("click","#my",function(){ 
    $(this).removeClass(this.title); 
    //or 
    $(this.title).remove(); 
    }); 
0

我想

$('#my').click(function(){ 
    $(this).removeClass(this.title); 
    $(this).addClass(this.title); 
    $(this).toggleClass(this.title); 
}) 

你正在尋找一個這些?