jQuery autoComplete view all on click?

后端 未结 22 2051
北恋
北恋 2020-12-02 09:52

I\'m using jQuery\'s autocomplete in a relatively simple way:

$(document).ready(function() {
  var data = [ {text: \"Choice 1\"}, 
               {text: \"Ch         


        
22条回答
  •  [愿得一人]
    2020-12-02 10:24

    I found this to work best

    var data = [
        { label: "Choice 1", value: "choice_1" },
        { label: "Choice 2", value: "choice_2" },
        { label: "Choice 3", value: "choice_3" }
    ];
    
    $("#example")
    .autocomplete({
        source: data,
        minLength: 0
    })
    .focus(function() {
        $(this).autocomplete('search', $(this).val())
    });
    

    It searches the labels and places the value into the element $(#example)

提交回复
热议问题