My intention is:
A listing where you can add <div>
and delete the divs added with a "button" inserted in each div
.
The page already comes with a fixed% inserted divs
that are the same as those that will be added.
The question is, in divs
that are already on the page, the delete button works correctly, now the divs
that are inserted with prepend
are not deleted. I already checked the remove()
function and all divs
both fixed and added have the same class. Anyway ...
list-mode
is the div
that encompasses all these divs
in html, .img_des_row
is div
that must be repeated and deleted ... Remember: add is working correctly!
JavaScript:
$("#bt-adicionar-imagens").click(function() {
$(".list-mode").prepend("< div class='img_des_row col-xs-12'>< div class='col-xs-8 no-pad-left'>< div class='description_img'>Lorem ipsum dolor sit amet consectetur adipisicing elit, sed do elusmod tempor.< /div>< /div>< div class='col-xs-2'><div class='pull-right margin-top_20 dropdown'><a href='#' class='icon-dwn-med pull-left margin_l_r_5'>< /a>< a href='#' class='icon-edit-med pull-left margin_l_r_5 dropdown-toggle' data-toggle='dropdown'>< /a>< div class='dropdown-menu alt-color-scheme left pad'>< /div>< a href='#' class='icon-trash-med pull-left margin_l_r_5'>< /a>< /div>< /div>< /div>");
});
$('.img_des_row .icon-trash-med').on('click', function(e) {
$(this).closest(".img_des_row").remove();
});