简体   繁体   English

输入上的keyup事件不起作用

[英]keyup event on input not working

In my code, both chrome and jsfiddle, find no errors, but while running it, it doesn't alerts anything. 在我的chrome和jsfiddle代码中,没有发现任何错误,但是在运行它时,它不会发出任何警报。

my code is: js: 我的代码是: js:

$("input#photoimg").on('keyup', function () {
    alert('key up');
});

html: HTML:

<input type="file" name="file" id="photoimg">

jsfiddle: http://jsfiddle.net/58nxY/1/ jsfiddle: http : //jsfiddle.net/58nxY/1/

For file inputs, use the change event: 对于文件输入,请使用change事件:

$("input#photoimg").on('change', function () {
    alert('file added/changed');
});

Updated fiddle 更新的小提琴

Keyup仅适用于文本输入,但是在文件和文档处理中,您需要触发“ change”事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM