How do I remove all tags in an input field below with jQuery?
<input class="form-control" id="videotags" data-role="tagsinput" placeholder="Video Tags" type="text">
//what I tried:
<script>$("#videotags").remove();</script>
How do I remove all tags in an input field below with jQuery?
<input class="form-control" id="videotags" data-role="tagsinput" placeholder="Video Tags" type="text">
//what I tried:
<script>$("#videotags").remove();</script>
This work for me:
$('#videotags').tagsinput('removeAll');
Try this
$('#videotags').click(function() {
var input = $(this);
input.val('');
});
$("#videotags").replaceWith(function () {
return $('<' + this.nodeName + '>').append($(this).contents());
});
Are the targets of removing not tags but attributes? The input tag in your question does not include tags.
If you want to remove all attributes in the input tags, I think you can use the method introduced in the below question.
bootstrap-tags.js do not provide to delete All tags at once. I have tried some workarounds for this. First I have fetch all the tags. Below is the code for that.
var tagData = $("#small").tags().tagData;
if (tagData.length > 0)
{
$.each( tagData, function( index, value ){
for(var tItem=0 ; tItem < tagData.length;)
{
$("#small").tags().removeTag(tagData[tItem]);
}
});
}
I have used 2 loops here as once you delete one record it will be reindex to 0.
© 2022 - 2024 — McMap. All rights reserved.