开发者

Detecting a context-menu paste in the browser with jquery

开发者 https://www.devze.com 2023-02-04 18:05 出处:网络
I am trying to check the length o开发者_如何转开发f the text in a textarea when someone pastes content in there via the right-click but can\'t seem to find how to do it.$(\'textarea\').bind(\'paste\',

I am trying to check the length o开发者_如何转开发f the text in a textarea when someone pastes content in there via the right-click but can't seem to find how to do it.


$('textarea').bind('paste', function() {
    var that = this;
    setTimeout(function() {
        var length = that.value.length;
        alert(length);    
    }, 0);

});

Live demo: http://jsfiddle.net/4UrE3/1/

Works in Firefox 3.6, Chrome, Safari and IE9 beta. Does not work in Opera.

0

精彩评论

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