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
You'd need to use event delegation for this, due to the elements being added/removed dynamically:
$('.content').on('click', '.emailTagRemove', function () {
var email = $(this).parents("li");
email.remove();
});
Use .content
as the selector as it's more efficient than using document
in this case.
jsFiddle here