Detecting a context-menu paste in the browser with jquery

╄→尐↘猪︶ㄣ 提交于 2019-11-27 18:35:22

问题


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:


$('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.



来源:https://stackoverflow.com/questions/4702814/detecting-a-context-menu-paste-in-the-browser-with-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!