这是我的 html 代码
< button class="send-report" name="submit" id="submit" type="submit" onclick="reportfeed()">Send Report< /button>
第一次点击时键盘消失,“reportfeed”功能仅在第二次点击时起作用(在 ipad 中)
function reportfeed()
{
alert(1);
}
我可以使用下面的代码,如果您知道任何其他方法,请帮助我
jQuery(".send-report").bind("click touchstart", function(){
reportfeed();
});
最佳答案
定义一个稍后可以使用的点击处理程序:
var clickHandler = ('ontouchstart' in document.documentElement ? "touchstart" : "click");
$(".send-report").bind(clickHandler, function(e) {
alert("clicked or tapped. This button used: " + clickHandler);
});
这将触发非触摸设备上的点击和触摸设备上的 touchstart。
使用.on()
,因为我认为.bind()
将从 future 的脚本中删除。
关于javascript - 第一次在 iPad 上点击按钮不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25604088/