【发布时间】:2021-03-19 03:20:36
【问题描述】:
我正在尝试在一个输入标签中添加两个两个functions。但是失败了很多次。
我想做什么?
在我的 HTML 模板中不同的 input 标签中有两个函数。
add tag, 一个。
第二个是autocomplete。
我正在尝试在同一个文本输入中添加自动完成和标签输入,所以我可以同时使用autocomplete 和add tag。
home.html
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/flick/jquery-ui.css">
<link href="{{ STATIC_URL }}user_tags/css/jquery.tagit.css" rel="stylesheet" type="text/css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="http://bootstrap-tagsinput.github.io/bootstrap-tagsinput/dist/bootstrap-tagsinput.css">
<script src="http://bootstrap-tagsinput.github.io/bootstrap-tagsinput/dist/bootstrap-tagsinput.min.js"></script>
#This function is for `autocomplete`.
<form>
<label for="product">Product</label>
<input type="text" name="product" id="product">
</form>
</form>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
#This function is for `add tag`
<b>Add Tags </b>
<input type="text" data-role="tagsinput" class="form-control" name="tags">
<br>
我尝试了什么?
我看到一个答案,如果我在两个标签的末尾添加semicolons,那么它会起作用,但它对我不起作用。
<form>
<label for="product">Product</label>
<input type="text" name="product" id="product"; data-role="tagsinput";>
</form>
我不知道该怎么办。
任何帮助将不胜感激。
【问题讨论】:
-
您可能需要澄清您正在尝试做什么。 “将它们加在一起”是什么意思?没有显示“添加标签”功能。
-
更新了问题
-
您不能将 javascript 函数包装在 HTML 标记中。在高层次上解释你想要做什么。忽略在标签中包装函数的想法。
-
我不想包装
javascript function in tag我只想将两个ids混合在一个input tag中。只是功能不全
标签: javascript python html django tags