Capture text pasted into a textarea with JQuery

后端 未结 4 542
甜味超标
甜味超标 2020-12-31 08:55

I have to take the paste event of a text area using JQuery. I have tried the following code but it is not working...

$(document).ready(function()
{ 
  $(\'#t         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-31 09:19

    You can do something like this

    $("#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);
    });
    

提交回复
热议问题