As piece of code is better than thousand word
// this is our dynamic created element.,
var $test = $('<button>If you add this event is working, if you remove this, and add again, event is not working...</button>');
// this is our event
$test.click(function(){
alert('Fooobar'); // fires only first time
});
// $test.on('click',function(){ <-- same behaviour
$('#add').click(function(){
$('#container').append( $test );
});
$('#remove').click(function(){
$('#container').html(''); // This is destroying all $test events!!!
});
How can i remove element, append it again and save events?
JS Fiddle:
I would like to remove element without destroying events.