Catch paste input

后端 未结 17 1918
名媛妹妹
名媛妹妹 2020-11-22 08:09

I\'m looking for a way to sanitize input that I paste into the browser, is this possible to do with jQuery?

I\'ve managed to come up with this so far:



        
17条回答
  •  -上瘾入骨i
    2020-11-22 08:30

    I sort of fixed it by using the following code:

    $("#editor").live('input paste',function(e){
        if(e.target.id == 'editor') {
            $('').attr('id', 'paste').appendTo('#editMode');
            $("#paste").focus();
            setTimeout($(this).paste, 250);
        }
    });
    

    Now I just need to store the caret location and append to that position then I'm all set... I think :)

提交回复
热议问题