2011-04-29 39 views
0

可能重複:
jQuery catch paste input的jQuery的拷貝到輸入

有jQuery中的事件處理程序中,我從剪貼板中選擇粘貼到輸入字段的事件?

至於據我所知沒有關鍵的運動,所以我會排除keyup和keydown。 點擊事件可能會反應,只要我點擊激活輸入字段,但不會得到內容,因爲他們被粘貼後,該事件。

任何輸入非常讚賞。

+0

這已被要求,並回答了[這裏](http://stackoverflow.com/questions/686995/jquery-catch-paste-input) 和[這裏](http://stackoverflow.com/questions/686995/jquery-catch-paste-input) – afranz409 2011-04-29 04:11:44

回答

6

是的,你可以使用'粘貼'事件。 下面是一個例子,對於複製,粘貼和削減#textA

$("#textA").bind('copy', function() { 
    alert('copy behaviour detected!') 
}); 
$("#textA").bind('paste', function() { 
    alert('paste behaviour detected!') 
}); 
$("#textA").bind('cut', function() { 
    alert('cut behaviour detected!') 
}); 
+0

它不工作,而我檢查在Firefox – AjayR 2013-11-06 00:53:31