Jquery-ui自动完成选定的值

时间:2018-04-10 07:05:53

标签: javascript jquery jquery-ui jquery-plugins

我希望得到这样的选定项目对象。

$("#tags").autocomplete('selected').val();

但我不知道如何获得所选对象。

我不想使用自动填充选择功能。

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,
      select:function(){}//I don't want use this.
    });

1 个答案:

答案 0 :(得分:0)

//Simply write and getting the selected value
$("#tags").val()
//Jsfiddle demo

https://jsfiddle.net/dintal/8eb0fopf/9/#&togetherjs=1rePhrjBBM