文本输入值,如选项标签

时间:2018-06-05 04:31:38

标签: javascript php jquery html

我不知道如何将它放入上下文中。我真的希望我的代码能解释这个条件。

<script>
  $( function() {
    var availableTags = [
      "ActionScript",
      "AppleScript",
      "Asp",
      "BASIC",
      "C",
      "C++",
      "Clojure",
      "COBOL",
      "ColdFusion",
      "Erlang",
      "Fortran",
      "Groovy",
      "Haskell",
      "Java",
      "JavaScript",
      "Lisp",
      "Perl",
      "PHP",
      "Python",
      "Ruby",
      "Scala",
      "Scheme"
    ];
    $( "#tags" ).autocomplete({
      source: availableTags
    });
  } );
  </script>
<fieldset>
  <span>
    <label>Auto Complete</label>
      <input type="text" id="tags" name="text" value=""/>
  </span>
</fieldset>

如何使文本输入显示js的完整选项,但值只有id1,id2,id3?有可能吗?

1 个答案:

答案 0 :(得分:1)

    <input list="tag">

    <datalist id="tag">
        <option value="ActionScript">
        <option value="AppleScript">
        <option value="Asp">
        <option value="BASIC">
        <option value="C">
        <option value="C++">
        <option value="Clojure">
        <option value="COBOL">
        <option value="ColdFusion">
        <option value="Erlang">
        <option value="Etc.">
    </datalist>