For example:
<input type="text" list="sample"/>
<datalist id="sample">
<option value="item 1"/>
<option value="item 2"/>
</datalist>
Is it possible to catch the event when an item from the datalist had been selected? Calling onclick or onchange on the input element don't work.
$(document).ready(function() {
$("#search").on("input", function(e) {
var val = $(this).val();
if(val === "") return;
....
var dataList = $("#searchresults");
dataList.empty();
your code...
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With