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

前端 未结 4 1707
-上瘾入骨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:39

    you can use the oninput event instead, modern browsers support this method

    http://jsfiddle.net/pxfunc/KDLjf/

    $('input').bind('input', function(e) {
        console.log($(this).val());
    }); 
    

提交回复
热议问题