jquery 事件处理程序 - 根据特定键和操作触发函数
背景故事:当用户用鼠标选择文本字段中的一部分文本(手动标记),然后点击“alt”键时,就会触发某个功能。
我的问题是:
- 当 用户按下某个键(在她的键盘上)?
- 如何保留所选文本的一部分并将其用作 该函数的参数?
我尝试在网上查找,但没有找到任何好的答案,但我也非常感谢链接。
Background story: when a user selects a portion of text in a text field with her mouse (mark it up manually), and subsequently hits "alt" key, a certain function would trigger.
My questions are:
- How can I trigger a function when a
user hits a key (in her keyboard)? - How can I preserve a portion of text selected, and use it as a
parameter for that function?
I've tried looking up online but haven't found any good answers, but i'd greatly appreciate links as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想获取文本输入或文本区域中选定的文本,您可以执行以下操作:
If you want to get the selected text in a text input or textarea you can do this: