Javascript OnPaste

后端 未结 2 405
野性不改
野性不改 2020-11-29 05:57

I have this right now:

This does infact work, except, it r

2条回答
  •  情深已故
    2020-11-29 06:38

    This is because the onpaste event fires before the content gets pasted into the element (link) so it's not there yet at the time you handle it.

    Modern browsers support methods of obtaining clipboard data inside the event handler. Refer to JavaScript get clipboard data on paste event (Cross browser) for cross-browser solution attempts.

    Also, you can always work around your issue by simply starting a timer in the event handler function (10ms should be enough) that would check your input value later.

提交回复
热议问题