问题
Is there a straightforward way to get the text in an awesomplete field (https://leaverou.github.io/awesomplete/)?
var input = document.getElementById("inputlist");
alert(input.value);
shows NaN!
回答1:
You need to add the event either awesomplete-select or awesomplete-selectcomplete
In regular Javascript
var input = document.getElementById("inputlist");
new Awesomplete(input, {list: yourlist});
document.getElementById('inputlist').addEventListener('awesomplete-selectcomplete',function(){
alert(this.value);
});
In Jquery
var input=$("#inputlist")[0];
new Awesomplete(input, {list: yourlist});
$("#inputlist").on('awesomplete-selectcomplete',function(){
alert(this.value);
});
来源:https://stackoverflow.com/questions/35864545/awesomplete-get-selected-text