jQuery bind to Paste Event, how to get the content of the paste

后端 未结 9 1040
温柔的废话
温柔的废话 2020-11-28 06:08

I have a jquery token tagit plugin and I want to bind to the paste event to add items correctly.

I\'m able to bind to the paste event like so:

    .b         


        
9条回答
  •  孤城傲影
    2020-11-28 06:47

    I recently needed to accomplish something similar to this. I used the following design to access the paste element and value. jsFiddle demo

    $('body').on('paste', 'input, textarea', function (e)
    {
        setTimeout(function ()
        {
            //currentTarget added in jQuery 1.3
            alert($(e.currentTarget).val());
            //do stuff
        },0);
    });
    

提交回复
热议问题