Jquery监听input事件


用Jquery动态生成了很多个input,每个input有id,怎么监听当前焦点所在的input的键盘事件(获取keyCode就行了)

jquery event JavaScript

饼梦幻想中 10 years, 11 months ago

input是动态生成的,绑定事件可以使用delgate,需要一个已知的父元素


 $("已知父元素").delgate("input","keydown"function (event) {
    alert(event.keyCode);
});

春哥的咆哮 answered 10 years, 11 months ago

Your Answer