我必须使用 JQuery 获取文本区域的粘贴事件。我已经尝试过以下代码,但它不起作用......
$(document).ready(function()
{
$('#txtcomplaint').keyup(function()
{
TextCounter('txtcomplaint','counterComplaint', 1000 );
})
$('#txtcomplaint').onpaste(function()
{
alert()
//TextCounter('txtcomplaint','counterComplaint', 1000 );
})
});
最佳答案
你可以做这样的事情
$("#txtcomplaint").bind('paste', function(e) {
var elem = $(this);
setTimeout(function() {
// gets the copied text after a specified time (100 milliseconds)
var text = elem.val();
}, 100);
});
关于jquery - 使用 JQuery 捕获粘贴到文本区域的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2242442/