In Jquery How to handle paste? [duplicate]

孤人 提交于 2019-12-01 03:33:20

问题


Possible Duplicates:
How do you handle oncut, oncopy, and onpaste in jQuery?
jQuery catch paste input

I have a textarea, on paste to that textarea I want to

  1. format pasting values
  2. append to textarea

could that be done in Javascript?


回答1:


There is an onpaste event that works in modern day browsers:

$("#textareaid").bind("paste", function(){});

Problem with the event, it tells you that it is about to happen, but it doesn't give you what the user is pasting. JavaScript has restricted acccess to the clipboard and by default it is disabled. If the access is enabled you can read the clipboard data and than manipulate it.



来源:https://stackoverflow.com/questions/7160073/in-jquery-how-to-handle-paste

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!