I've a form with an empty input#tags.
I have a p#list_tags with few span.keyword.
When I click a .keyword, its text append to input.val()
But I can't remove its text from val() if I click on it again.
My code :
$("p#list_tags span.keyword").click(function() {
var tag = $(this).text();
var tags = $("#tags").val();
if($(this).hasClass('selected_tag')) {
$(this).removeClass('selected_tag');
// Here, I don't know what to do... I've tried this, but...
// $("#tags").remove(":contains('" + tag + "')");
}
else {
$("#tags").val(tags + ' ' + tag);
$(this).addClass('selected_tag');
}
});