I try to figure out how to update the element LI after use insertBefore function jQuery.
The problem is after add any new elements to UL, I can not delete the element sa
Because those are dynamically added elements to the existing HTML, so you need to delegate it using on event handler attachment with the document
.
$(document).on('click','.emailTagRemove', function () {
var email = $(this).parents("li");
email.remove();
});
JSFiddle
As @null pointed using the static selector instead of document is good, in order to avoid conflict among those elements in entire code.
$('#ulEmailsCotacao').on('click','.emailTagRemove', function () {
var email = $(this).parents("li");
email.remove();
});
JSFiddle