I have a DIV that when click on it, it will add another DIV inside itself. Then if I click the newly added DIV it will remove it.
HTML
<div id="container"></div>
jQuery
$('#container').on('click', function(e){
// Add other DIV
$( this ).append('<div class="other">XYZ</div>');
e.stopPropagation();
// Remove other DIV
$('div.other').bind('click', function(event){
$( this ).remove();
event.stopPropagation();
});
});
How efficient is this method if I plan to have to lot of child DIVs?
bind, useonbind-- there's nothing wrong with it.