粘贴事件

Avatar of Chris Coyier
Chris Coyier
$.fn.pasteEvents = function( delay ) {
    if (delay == undefined) delay = 20;
    return $(this).each(function() {
        var $el = $(this);
        $el.on("paste", function() {
            $el.trigger("prepaste");
            setTimeout(function() { $el.trigger("postpaste"); }, delay);
        });
    });
};

在元素上调用此插件,然后您将获得粘贴之前和之后的回调事件

$("#some-element").on("postpaste", function() { 
    // do something
}).pasteEvents();