问题描述
好吧,所以我有一个输入框,我需要做的事情,每当它改变,我无法做到这一点鼠标粘贴。这是我的代码 $(#attack-navy+ unit.ID + - number)bind 'paste',function(){
alert(paste detected);
$(#attack-max-capacity)。text(getMaxCapacity());
});
现在输入的getMaxCapacity()函数返回号码* 30;
这里是
1的情况:我粘贴3,它不会改变(我仍然看到警报)
2:那么当我粘贴5,这将是90(3 * 30)
3:那么如果我粘贴10,将是150(5 * 30),等等。
我认为在粘贴实际发生之前,它执行处理程序。有什么想法可以做什么? (.change将不起作用,一旦你粘贴就必须这样)
你应该处理输入
和 propertychange
事件。
。
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());
});
the getMaxCapacity() function return number entered * 30 for now;
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.
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)
You should handle the input
and propertychange
events.
Demo.
这篇关于Jquery / JS绑定“粘贴”事件处理程序输入文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!