I have a text field which is empty, but when you click in it it has some suggestions from previous inputs.
Which JavaScript event is fired if i choose one of them wi
the oninput event triggered.
try:
title
the diffrence between oninput,onpropertychange,onchange:
onchange fired only when
a)the property changed by user interface
b)and the element lost focus
onpropertychange fires when property change. but it is IE only
oninput
oninput is the W3C version of onpropertychange . IE9 begin surport this event .
oninput fired only when the element value changes.
so if you want compacity in all browsers
IE<9 use onpropertychange
IE>9 and other broweser use oninput
if you use jQuery , you can bind two event that share the same hander
$(function($) {
//the same handler
function oninput(e){
//do sth
}
$("#ipt").on("input", function(e){
console.log("trigger by oninput");
oninput(e);
})
$("#ipt").on("propertychange", function(e) {
console.log("trigger by propertychange");
oninput(e);
})
})
demo at http://output.jsbin.com/salekaconi