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.