Ama*_*man 8 jquery twitter-bootstrap-3 bootstrap-tags-input
我试图使用没有Typeahead的Bootstrap标签输入插件.我已经包含以下文件:
<link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="../../tagsinput/css/bootstrap-tagsinput.css" rel="stylesheet" type="text/css">
<script src="../../tagsinput/js/bootstrap-tagsinput.min.js"></script>
Run Code Online (Sandbox Code Playgroud)
脚本如下:
<script>
$('#tagPlaces').tagsinput({
allowDuplicates: true
});
</script>
Run Code Online (Sandbox Code Playgroud)
使用插件的JSP表单的一部分:
<div class="form-group">
<label for="tagPlaces" class="col-sm-2 control-label">Tag Places</label>
<div class="col-sm-10">
<input type="text" class="form-control" data-role="tagsinput" id="tagPlaces">
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
但我无法在输入字段中看到标签.当我按下输入标签时,我的表单也会被提交.请提出我缺少的内容以及使用该插件的正确方法.
小智 18
这就是我做到的
<script src="../js/bootstrap-tagsinput.js"></script>
no more javascript
Run Code Online (Sandbox Code Playgroud)
Css
您可以包含原始引导标记输入css文件
<link rel="stylesheet" href="../css/bootstrap-tagsinput.css">
Run Code Online (Sandbox Code Playgroud)
或者你只能使用它
.bootstrap-tagsinput {
background-color: #fff;
border: 1px solid #ccc;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
display: block;
padding: 4px 6px;
color: #555;
vertical-align: middle;
border-radius: 4px;
max-width: 100%;
line-height: 22px;
cursor: text;
}
.bootstrap-tagsinput input {
border: none;
box-shadow: none;
outline: none;
background-color: transparent;
padding: 0 6px;
margin: 0;
width: auto;
max-width: inherit;
}
Run Code Online (Sandbox Code Playgroud)
和HTML
<input type="text" value="" data-role="tagsinput" id="tags" class="form-control">
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
31156 次 |
| 最近记录: |