Get value in jquery autocomplete

前端 未结 3 1129
鱼传尺愫
鱼传尺愫 2020-12-10 15:36

Here is my code

jquery code

$(\"input#shopName\").autocomplete({
    source: \"getShop.php\",
    minLength: 2
});

The JSON value r

相关标签:
3条回答
  • 2020-12-10 15:52
    $("input#shopName").autocomplete({
        source: "getShop.php",
        minLength: 2,
        select: function(event, ui) { 
            $("#theHidden").val(ui.item.id) 
        }
    });
    

    See http://jqueryui.com/demos/autocomplete/#event-select

    0 讨论(0)
  • 2020-12-10 15:53

    Use the following to get chosen value onClick

       $( "#searchText" ).bind( "autocompleteselect", function(event, ui) {
        console.log(ui['item']['value']);
        }); 
    
    0 讨论(0)
  • 2020-12-10 16:04

    This works for me fantastically:

    $(ui)[0].item.label
    $(ui)[0].item.value
    
    0 讨论(0)
提交回复
热议问题