【问题标题】:Awesomplete - get selected textAwesomplete - 获取选定的文本
【发布时间】:2016-06-22 05:33:07
【问题描述】:

有没有一种直接的方法可以在一个很棒的字段 (https://leaverou.github.io/awesomplete/) 中获取文本?

var input = document.getElementById("inputlist");
alert(input.value);

显示 NaN!

【问题讨论】:

    标签: javascript autocomplete autocompletebox


    【解决方案1】:

    您需要添加事件 awesomplete-select 或 awesomplete-selectcomplete

    在普通的 Javascript 中

    var input = document.getElementById("inputlist"); 
    new Awesomplete(input, {list: yourlist});
    document.getElementById('inputlist').addEventListener('awesomplete-selectcomplete',function(){
      alert(this.value); 
    });  
    

    在 Jquery 中

    var input=$("#inputlist")[0];
    new Awesomplete(input, {list: yourlist});
    $("#inputlist").on('awesomplete-selectcomplete',function(){
      alert(this.value);
    });
    

    【讨论】:

      猜你喜欢
      • 2019-09-29
      • 2020-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-07
      相关资源
      最近更新 更多