Best way to track onchange as-you-type in input type=“text”?

后端 未结 16 1131
天命终不由人
天命终不由人 2020-11-22 08:42

In my experience, input type=\"text\" onchange event usually occurs only after you leave (blur) the control.

Is there a way to

16条回答
  •  隐瞒了意图╮
    2020-11-22 09:08

    Method 1: Add an event listener for input:

    element.addEventListener("input", myFunction);
    

     

    Method 2: Define the oninput property with JavaScript:

    element.oninput = function()
    {
        myFunction();
    };
    

     

    Method 3: Define the oninput property with HTML:

    
    

提交回复
热议问题