I would like to add a class or other attributes to the input generated by bootstrap
<input type="text" value="">
$('input').tags-input();
generates:
<div class="bootstrap-tagsinput">
<input type="text" placeholder="add tags" style="width: 8em !important;">
</div>
I would like to add a class with: https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/
input
Returns the tagsinput's internal , which is used for adding tags. You could use this to add your own typeahead behaviour for example.
var $elt = $('input').tagsinput('input');
I don't seem to understand how would a class be added
Thank you
Firstly, tagsinput is initialized like this
$("input").tagsinput();
The method tagsinput('input')
returns the input element to which other jQuery methods can be used like this
var $input = $("input").tagsinput('input');
$input.addClass('custom-class');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With