2016-09-26 103 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,從而爲其設置樣式。如果回答你的問題,你介意接受答案嗎? –