此 Meteor 客户端代码有 2 个按钮,“CLEAR”按钮假设用于清除输入框,注意到以下行为:
1) 火狐浏览器; windowsXP 上的 52.2.1 和 Mac 上的 54.1 不会清除输入框,而是调用 clickInfo()
。
2) 在以下浏览器上运行良好:
a) Mac 上的 Chrome 59
b) Safari 10.2
c) Android 上的 Chrome
代码需要能够通过单击/点击 INFO 按钮或按键盘上的 ENTER 键来调用 clickInfo()
。
知道如何使用 CLEAR 按钮来清除所有浏览器上的输入框吗?谢谢
Template.footer.events({
'click #clear': () => {
event.preventDefault();
dict.set('busy', false);
dict.set('prop1', '');
let elem = document.getElementById('prop1');
elem.value = '';
elem.focus();
},
'click #info': function () {
event.preventDefault();
clickInfo();
}
});
Template.body.events({
'submit form': function (event) {
event.preventDefault();
clickInfo();
}
});
<head>
<title>myTitle</title>
<link rel="apple-touch-icon" href="/appIcon.png"/>
<link rel="apple-touch-icon-precomposed" href="/appIcon.png"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
{{> header}}
<div id="main">
<div id="login-div">{{> loginButtons align='right'}}</div>
<div id="content">
<form>
<button type="submit" style="display:none"></button>
{{> content}}
{{> footer}}
</form>
</div>
</div>
</body>
<template name="footer">
<footer>
<button id="clear">CLEAR</button>
<button id="info">INFO</button>
</footer>
</template>
最佳答案
像这样使用'提交表单':function (e) {
,
使用e代替事件
关于javascript - 仅在 Firefox 上单击按钮才能提交表单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45396402/