1

I am trying to add a listener with input element on propertychange, but it's not working at all.. I tried with chrome as well ie11 both not responding.

is my approach is wrong or is it require any other workarounds?

here is my code :

<form>
    <fieldset>
        <label>Username: <input type="text" /></label>
    </fieldset>
</form>

var callme = function () {
    console.log('i am called'); // not calling chrome, ie..
}


$('input[type=text]').on('propertychange', callme);

thanks in advance!

Live Demo

4

1 回答 1

1

首先将您的 JS 代码封装在$(document).ready(function(){});I can't see you did,但也许您做到了。

在 HTML5 中有一个新事件“input”,它的行为与您认为“change”应该表现的完全一样——因为它会在按下一个键以将信息输入表单时立即触发 在旧的 HTML5 之前浏览器,“keyup”绝对是你要找的。

使用事件 .on('input')。

请参阅工作示例:jsfiddle.net/5ex4V/1/

于 2014-06-25T07:35:18.943 回答