I use jquery to add tag dynamically, but I face some problems. I can remove the tags in original code, however, I can't remove the tag which is added by jquery.
Another question is how could I avoid adding duplicated tag (same value)? Many thanks!
<div id='searchTerm' class='searchTerm'>
<span><b>U.S.A</b><a class="remove" href="#"></a></span>
<span><b>H.K.</b><a class="remove" href="#"></a></span>
</div>
$('document').ready(function(){
$('#addTag').click(function() {
var html='';
html += '<span><b>' + $("#newTag").val() + '</b><a class="remove" href="#"></a></span>';
$('#searchTerm').append(html);
});
$('.remove').click(function() {
$(this).parent().remove();
});
});