med*_*zid 9 javascript jquery textarea
我想捕获textarea(keyup,以及copy和past)中发生的变化,我使用的keyup选项:
$("textarea").keyup(function(){
// ajax call here
});
Run Code Online (Sandbox Code Playgroud)
我添加了这个以捕获粘贴或通过鼠标切割然后触发textarea上的keyup事件:
$("textarea").on('input propertychange', function() {
$(this).trigger(keyup);
});
Run Code Online (Sandbox Code Playgroud)
这里的问题是,如果我按下键盘上的一个键,我得到2个ajax调用,因为第二个函数捕获也是键盘事件.
有没有办法防止$("textarea").on('input propertychange'...
检测到按键?
为什么不测试这种简化?当我测试你的代码时,没有成功检测'input propertychange'事件中的keyup.
//$("textarea").keyup(function(){
//// ajax call here
//});
Run Code Online (Sandbox Code Playgroud)
$("textarea").on('input propertychange', function() {
//$(this).trigger(keyup);
// do ajax call here
});
Run Code Online (Sandbox Code Playgroud)
后者仅忽略一些控制键,即没有相应字符输入的键.