使用jquery / javascript检测文本输入框中的更改

在html和javascript中,我可以使用keyup,focus,blur来检测文本输入中的大部分内容更改,但是如果用户复制并粘贴到文本输入中,我该如何捕获此更改? 这里的问题是当用户粘贴输入时输入已经成为焦点。

您可以捕获粘贴事件( http://www.quirksmode.org/dom/events/cutcopypaste.html

$("#myinput").bind("paste",function(){ //code here }) 
 $("#myinput").change(function(){ // whatever you need to be done on change of the input field }); // Trigger change if the user type or paste the text in the field $("#myinput").keyup(function(){ $(this).change(); }); // if you're using a virtual keyboard, you can do : $(".key").live('click',function(){ $("#myinput").val($("#myinput").val()+$(this).val()); $("#myinput").change(); // Trigger change when the value changes }); 

文本框有一个OnChange事件,当a)文本框失去焦点并且文本框中的值发生变化时触发该事件。