【问题标题】:jQuery autocomplete: How to separate the url of the javascript?jQuery自动完成:如何分隔javascript的url?
【发布时间】:2012-04-03 15:15:12
【问题描述】:

对于一个网站,我会在不同的页面上有很多自动完成的字段。

它们在所有页面上的工作方式完全相同,只是它们不能调用相同的 url。

我想知道是否有可能在 <input> 上提及 URL,这将是一个自动完成字段?目标是为多个 html 代码提供一个 js 代码

我尝试了一些方法,但它似乎不起作用: html:

<input type="field" name="search" class="autocomplete" value="Search" url="smalltest/otherTest/..." />

还有 JS

$(document).ready(function () {
    $("input.autocomplete").autocomplete({
        source: $(this).attr("url")
    }); });

我在 jquery 库中遇到异常。

【问题讨论】:

    标签: javascript jquery jquery-ui autocomplete jquery-autocomplete


    【解决方案1】:

    将 url 属性更改为 data-url 然后在您的 .autocomplete 中执行以下操作:

    source: $(this).data("url")

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-13
      • 2015-09-14
      • 1970-01-01
      • 2011-02-02
      • 1970-01-01
      相关资源
      最近更新 更多