按键事件在 Mozilla Firefox 中不起作用
按键事件在 Mozilla Firefox 中不起作用。 我动态创建了一个表行,其中包含一个文本框,并且该文本框也有一个按键事件。
var el = document.createElement('input');
el.type = 'text';
el.name = 'suggest2';
el.setAttribute("id",str2);
el.setAttribute("onkeypress","additemifenter(this.id)");
cell2.appendChild(el);
row.appendChild(cell2);
在 google chrome 中,调用函数 additemifenter(this.id) 。但在 Firefox 中该函数没有被执行。在 Firefox 中执行此操作的替代方法是什么?
Key press event is not working in Mozilla Firefox.
I have create a table row dynamically with a text boix in it and that text box has a key press event too.
var el = document.createElement('input');
el.type = 'text';
el.name = 'suggest2';
el.setAttribute("id",str2);
el.setAttribute("onkeypress","additemifenter(this.id)");
cell2.appendChild(el);
row.appendChild(cell2);
In google chrome the function additemifenter(this.id) is called. But in firefox that function is not getting executed. What is the alternate way to do this in firefox?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许末尾的分号会有所帮助
,但
为什么不使用标准事件处理模型:
或者
要检查密钥代码,您必须使用以下代码:
Maybe the semicolon at the end would help
but
why don't you use the standard event handling model:
or
to check the keycode you must use the code: