一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

jquery中监听粘贴事件函数

时间:2014-05-26 编辑:简简单单 来源:一聚教程网

 代码如下 复制代码

// 粘贴事件监控
$.fn.pasteEvents = function( delay ) {
    if (delay == undefined) delay = 10;
    return $(this).each(function() {
        var $el = $(this);
        $el.on("paste", function() {
            $el.trigger("prepaste");
            setTimeout(function() { $el.trigger("postpaste"); }, delay);
        });
    });
};

// 使用
$("input[type='text']").on("postpaste", function() {
    // code...
}).pasteEvents();

热门栏目