問題描述
好的,所以我有一個輸入框,每次更改時我都需要做一些事情,我在鼠標粘貼時遇到了麻煩.這是我的代碼
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 綁定“粘貼"輸入文本框的事件處理程序的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!