For instance:
<input type="text" list="sample"/> <datalist id="sample"> <option value="item 1"/> <option value="item 2"/> </datalist>
Is it possible to catch an event when an item was selected from the data catalog? Calling onclick or onchange on an input element does not work.
$(document).ready(function() { $("#search").on("input", function(e) { var val = $(this).val(); if(val === "") return; .... var dataList = $("#searchresults"); dataList.empty(); your code... }); });
Datalistused to storage and Auto list Purpose... It doesn't have Selected Events..
Datalist
storage and Auto list Purpose
doesn't have Selected Events
if you want to get elements in a datalist ... just loop it and get the data ...
$('#sample option').each(function(index) { alert($(this).val()); });