开发者

jQuery on copy into input [duplicate]

开发者 https://www.devze.com 2023-03-01 05:54 出处:网络
This question already has answers here: 开发者_如何学C Closed 10 years ago. Possible Duplicate: jQuery catch paste input
This question already has answers here: 开发者_如何学C Closed 10 years ago.

Possible Duplicate:

jQuery catch paste input

is there an event handler in jQuery for the event in which I paste a selection from the clipboard into an input field?

As for as I know there is no key movement involved so I would rule out keyup and keydown. Click event would probably react as soon as I click to active the input field but would not get the contents as they are pasted after that event.

Any input much appreciated.


Yes, you can use the 'paste' event. Here's an example, for copy, paste and cut for #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

精彩评论

暂无评论...
验证码 换一张
取 消