Jib*_*oor 12 jquery copy-paste javascript-events
我必须使用JQuery来获取文本区域的粘贴事件.我尝试了以下代码,但它不起作用......
$(document).ready(function()
{
$('#txtcomplaint').keyup(function()
{
TextCounter('txtcomplaint','counterComplaint', 1000 );
})
$('#txtcomplaint').onpaste(function()
{
alert()
//TextCounter('txtcomplaint','counterComplaint', 1000 );
})
});
Run Code Online (Sandbox Code Playgroud)
rah*_*hul 25
你可以做这样的事情
$("#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);
});
Run Code Online (Sandbox Code Playgroud)
Run Code Online (Sandbox Code Playgroud)$('#txtcomplaint').bind('paste', function(e){ alert('pasting!') });
有关其他资源,请查看此处.