I’m adding tags to a label on click by doing the following in jQuery
$('.addTag').live('click', function () {
$('.pendingTags').html($('.pendingTags').html() + $('.newTag').val() + ', ');
});
But what I need to do is see if the $('.newTag').val() already exists in the text/html of .pendingTags
Any idea how I can accomplish this?
Thanks
Use the
.text()method, rather than the.html()method. Also, you should add the comma before the new tag.