【问题标题】:Adding two functions in one input tag在一个输入标签中添加两个函数
【发布时间】:2021-03-19 03:20:36
【问题描述】:

我正在尝试在一个输入标签中添加两个两个functions。但是失败了很多次。

我想做什么?

在我的 HTML 模板中不同的 input 标签中有两个函数。

add tag, 一个。

第二个是autocomplete

我正在尝试在同一个文本输入中添加自动完成和标签输入,所以我可以同时使用autocompleteadd 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


【解决方案1】:

我对你在问什么感到困惑。如果您尝试标记要由不同查询选择的元素(输入),则可以使用类。如果您尝试通过一个函数调用运行 2 个函数,请将这两个函数包装在一个函数中。

【讨论】:

  • 如何将两个函数包装在一个输入标签中?
  • 您不能将 javascript 函数包装在 html 标签中。
  • 我不想包装javascript function in tag 我只想将两个ids 混合在一个input tag 中。只是功能不全
  • 你不能给一个元素两个 id。它们是一对一的关系。这就是课程的用途。 class = "class1 class2"
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-07-23
  • 1970-01-01
  • 2012-10-09
  • 2021-12-16
  • 1970-01-01
  • 2021-12-05
  • 1970-01-01
相关资源
最近更新 更多