jQuery 'input' event

2018-12-31 15:43发布

I've never heard of an event in jQuery called input till I saw this jsfiddle.

Do you know why it's working? Is it an alias for keyup or something?

$(document).on('input', 'input:text', function() {});

8条回答
查无此人
2楼-- · 2018-12-31 16:24

jQuery has the following signature for the .on() method: .on( events [, selector ] [, data ], handler )

Events could be anyone of the ones listed on this reference:

https://developer.mozilla.org/en-US/docs/Web/Events

Though, they are not all supported by every browser.

Mozilla states the following about the input event:

The DOM input event is fired synchronously when the value of an or element is changed. Additionally, it fires on contenteditable editors when its contents are changed.

查看更多
余生无你
3楼-- · 2018-12-31 16:24
$("input#myId").bind('keyup', function (e) {    
    // Do Stuff
});

working in both IE and chrome

查看更多
登录 后发表回答