jQuery 客户端事件在 Safari 5.1 中不起作用



我正在使用jQuery Mobile开发一个移动网站。Safari 浏览器 (5.1) 不识别 jQuery 点击事件 - 如 ("#button1").click (function (){ ...... });

知道吗?

代码片段:

$("#submit").click(function () {
    alert("hello");
});
<form id="loginForm" class="validate" action=""  method="get">
<input type="button" id="submit" name="submit" value="LOGIN" /> </form>
$("#submit").on("click", function () {
      alert("hello");
});

请参考

.on()

j查询移动事件

JavaScript click 事件并不总是在某些移动浏览器中触发,因此您可能还必须绑定到 tap 事件,如下所示:

$("#submit").bind("click tap", function () {
      alert("hello");
});

有关jQuery Mobile事件的更多信息,请访问:http://jquerymobile.com/test/docs/api/events.html