For example, I have the following input and datalist. After select option "a" from dropdown list, how to trigger a function?
The current way is only working after the focus is removed from input. What I want is, right after click the option, then it will trigger another function,Like trigger the javascript function?
I tried "onchange" and "onclick", it has to remove the focus. I want the action being triggered after option is selected.
<input id="endpointsInput_1" name="endpointsname_1" list="endpointsname_1" class="form-control" type="text" style="display:inline-block;width:100%;" onclick="getJsonRequest(1);"/>
<datalist id="endpointsname_1">
<option value="a">a</option>
<option value="b">b</option>
<option value="folders/delete">folders/delete</option>
<option value="c">c</option>
</datalist>
my script is as below.
<script type="text/javascript">
function getJsonRequest(i){
$("input[name=endpointsname_"+i+"]").change(function () {
alert($(this).val());}