bootstrap-tags-input将一个类添加到生成的输入中 [英] 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();
生成:
<div class="bootstrap-tagsinput">
<input type="text" placeholder="add tags" style="width: 8em !important;">
</div>
我想添加以下类:
https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/
输入
返回标签输入的internal,用于添加标签。例如,您$ b $ b可以使用它来添加自己的预输入行为。
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
谢谢
推荐答案
首先,将标签输入初始化为
Firstly, tagsinput is initialized like this
$("input").tagsinput();
方法 tagsinput('input')
返回可以使用其他jQuery方法的输入元素
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');
这篇关于bootstrap-tags-input将一个类添加到生成的输入中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!