Jquery / JS bind quot;pastequot; event handler to input textbox(Jquery/JS 绑定“粘贴输入文本框的事件处理程序)
问题描述
好的,所以我有一个输入框,每次更改时我都需要做一些事情,我在鼠标粘贴时遇到了麻烦.这是我的代码
Allright, SO i have an input box and I need to do things everytime it changes, I am having trouble doing it for mouse paste. Here is the code I have
$("#attack-navy"+unit.ID+"-number").bind('paste', function(){
alert("paste detected");
$("#attack-max-capacity").text(getMaxCapacity());
});
getMaxCapacity() 函数现在返回输入的数字 * 30;
the getMaxCapacity() function return number entered * 30 for now;
这是当
1:我粘贴了 3,它不会改变(我仍然看到警报)
2:那么当我粘贴 5 时,它将是 90(3 * 30)
3:那么如果我粘贴 10,它将是 150(5 * 30),依此类推.
Here is the scenario when
1: I paste 3, it will not change (i still see the alert)
2: Then when i paste 5, it will be 90(3 * 30)
3: Then if i paste 10 it will be 150(5 * 30), and so on.
我认为它在粘贴实际发生之前执行处理程序.关于我能做什么的任何想法?(.change 不起作用,它必须在你粘贴后立即发生)
I think its doing the handler before the paste actually occurs. Any ideas on what I can do? (.change will not work, it must happen as soon as u paste)
推荐答案
您应该处理 input
和 propertychange
事件.
演示.
You should handle the input
and propertychange
events.
Demo.
这篇关于Jquery/JS 绑定“粘贴"输入文本框的事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Jquery/JS 绑定“粘贴"输入文本框的事件处理程序


基础教程推荐
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01