0

I have delete buttons that are added to the page dynamically.

I use this, for when delete is pressed:

 $('#gallery').on('click', '.btn-delete', function(){

 });

But how can I get the instance of the delete button pressed inside the on fnc? I've tried this, but no luck:

$(this).addClass('btn-danger');
4

1 回答 1

0

你可以试试 jQuery 委托

$('#gallery').delegate('.btn-delete', 'click', function(){
    $(this).addClass('btn-danger');
});

但据我所知,它相当于 on event..

于 2013-10-02T15:40:15.617 回答