2016-09-26 62 views
0

HTML:初始化输入标签作为标签输入的行为奇怪

<input type='text'id='some_id' class='form-control', data-role='tagsinput' /> 

JS:

$("input").tagsinput(); 

,但它改变输入tasg的风格display='none',并增加了一个额外股利。

下面是返回的HTML:

<div class="bootstrap-tagsinput"> <input type="text" placeholder="" size="1"></div> 
<input class="form-control" data-role="tagsinput" id="some_id" style="display: none;" type="text"> 

enter image description here

enter image description here

为什么它是行为古怪?

回答

0

这并不奇怪,它运行正常。当您执行$("input").tagsinput();时,库将采用该文件input,将其包装为其它样式的其他标记,并添加所需的特殊行为(即标记)。这是JavaScript库中的常见现象。

+0

如何为标记添加自定义样式? –

+0

您可以查看呈现的html和类,并编写定位这些元素的自定义CSS,从而为其设置样式。如果回答你的问题,你介意接受答案吗? –