jQuery 中触发退格键
如何在 jQuery 中触发退格键事件?
以下示例不起作用:
var e = jQuery.Event("backspace", { keyCode: 8 });
$("#myarea").trigger( e );
How can I trigger the backspace key event in jQuery?
The following example isn't working:
var e = jQuery.Event("backspace", { keyCode: 8 });
$("#myarea").trigger( e );
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你实际上无法触发它。
例如,您可以从某个输入中删除最后一个字符,但无法触发实际的键。
例子:
You can't actually trigger it.
You could, for example, remove the last character from a certain input, but you can't trigger the actual key.
Example:
您无法触发退格键。
使用 jquery caret 插件,您可以通过删除正确的字符来模拟按退格键。
请参阅 此 jsfiddle (您可能需要更改插入符号插件源)
You can't trigger the backpace key.
With the jquery caret plugin, you can simulate the press on the backspace key by removing the correct characters.
See this jsfiddle (you might need to change the caret plugin source)