I am trying to call keyup event using EventListener for input tag but it is not working and I don't know why. below is my code
document.getElementById("ajax").addEventListener("keyup", function() {
alert("called");
});
<input type="text" id="ajax" list="json-datalist" placeholder="e.g. datalist">
<datalist id="json-datalist"></datalist>
Even if I tried JQuery but still it is not working but if I use
document.addEventListener(keyup,function(){
alert("called");
});)
then this is working but this is not what I want Help will be appriciated
Your JavaScript Code is working
Try Following Using Jquery
$('#ajax').keypress(function(){
alert('called')
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="ajax" list="json-datalist" placeholder="e.g. datalist">
<datalist id="json-datalist"></datalist>
You can Try Using jquery
Keyup Event
$(document).on('keyup','#ajax',function(){
alert('Called');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="ajax" list="json-datalist" placeholder="e.g. datalist">
<datalist id="json-datalist"></datalist>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments