jquery keyup detect paste text from input

后端 未结 2 595
遇见更好的自我
遇见更好的自我 2021-01-01 17:12

I have to use here jquery keyup to detect if user enter any text or not, but my problem is if user use paste the text using mouse, it won\'t be able to dete

相关标签:
2条回答
  • 2021-01-01 17:20

    In this particular situation enough will be just bind to the input event:

    $('textarea').bind("input", function() {});
    
    0 讨论(0)
  • 2021-01-01 17:41

    Apparently there are some situations where jQuery doesn't work for pasting. You might need to bind to several events as shown in following reference to catch users pasting contents accurately.

    From Soliciting Fame - jQuery keyup vs bind - (from way-back machine)

    // detect the change
    $('input#myId').bind("change keyup input",function() { 
        // handle events here
    });
    
    0 讨论(0)
提交回复
热议问题