Which Event is fired? (javascript, input-field-history)

javascript

Solution

the oninput event triggered.

try:

    <!doctype html>
    <html>
        <head>
            <meta charset="utf-8">
            <title>title</title>
        </head>
        <body>
            <form method="get" id="" action="">
                <input type="text" name="name" oninput="alert('oninput')"/>
                <input type="submit" value="done"/>
            </form>
        </body>
    </html>

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

Problem

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 with the mouse? i'm using jquery 1.6.2 for binding the listeners: ``` view.textRegistrations.bind("blur change keyup", function(event) { //do Something }); ```

Original source