jQueryでコピー、ペースト、カットの動作を検出する方法

jQueryでコピー、貼り付け、切り取りの動作を検出する方法

コピー、貼り付け、切り取りの動作を検出するには、対応するイベントタイプをバインドするだけです。

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

jQuery 1.4xを使用している場合、次のような複数イベント宣言をサポートしています。

$("#textA").bind({
    copy : function(){
        $('span').text('copy behaviour detected!');
    },
    paste : function(){
        $('span').text('paste behaviour detected!');
    },
    cut : function(){
        $('span').text('cut behaviour detected!');
    }
});

自分で試してください









  

jQuery copy, paste and cut example