本文主要记录使用jQuery监听剪贴、复制、粘贴等动作来执行一些需要的代码。
$('input').bind('paste', function () {
var element = this;
setTimeout(function () {
var text = $(element).val();
//do something with text
}, 100);
});
$('#editor').live('input paste', function (e) {
if (e.target.id == 'editor') {
$('<textarea></textarea>').attr('id', 'paste').appendTo('#editMode');
$('#paste').focus();
setTimeout($(this).paste, 250);
}
});
$('#Text1').bind('copy', function (e) {
alert('copying text!');
});
$('#Text1').bind('paste', function (e) {
alert('pasting text!');
});
$('#Text1').bind('cut', function (e) {
alert('cut text!');
});
