Is it possible to get pasted text without using the setTimeout() function?

前端 未结 4 1698
-上瘾入骨i
-上瘾入骨i 2021-01-02 15:47

I found out that when pasting text (i.e. Hello) by using the mouse, the following function will throw an empty popup:

$(\'input:text\').onpaste          


        
4条回答
  •  北海茫月
    2021-01-02 16:32

    I don't think the bellow code works on IE8 since the input value is not changed when alert() executed.

     $('input').bind('input paste', function(e) {
         alert($(this).val());
     }); 
    

    on Firefox and Chrome, it works fine.

提交回复
热议问题