Detecting a context-menu paste in the browser with jquery

前端 未结 1 1479
悲&欢浪女
悲&欢浪女 2020-12-17 01:06

I am trying to check the length of 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.

相关标签:
1条回答
  • 2020-12-17 02:01
    $('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 讨论(0)
提交回复
热议问题