Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap-tags-input adding a class to the generated input

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

like image 277
Chilianu Bogdan Avatar asked Jul 05 '15 15:07

Chilianu Bogdan


1 Answers

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');
like image 63
Dhiraj Avatar answered Oct 16 '22 02:10

Dhiraj