jQuery .tap事件无法正常工作

Tho*_*vin 5 javascript jquery

我无法弄清楚为什么jQuery tap事件在测试时甚至没有响应.我发出了警报,我根本没有弹出它.我的代码看起来像这样:

var calendarOpen = false;

$('.calendar').on("tap", function () {
alert('1'); 
    if (calendarOpen == false) {
        $('.login-body').animate({left: '90%'}, 300);
        $('.calendar-body').animate({right: '10%'}, 300);
        calendarOpen = true;
    } else {
        $('.login-body').animate({left: '0px'}, 300);
        $('.calendar-body').animate({right: '50%'}, 300);
        calendarOpen = false;
    }
});
Run Code Online (Sandbox Code Playgroud)

我附上了脚本和CSS页面,我检查过任何拼写错误.我复制了jQuery文档,但我仍然遇到问题.谢谢您的帮助.

这些是我包含的脚本,上面提供的代码在main.js下.

<script src=http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js></script>
<script src=http://code.jquery.com/ui/1.10.3/jquery-ui.js></script>
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script src="scripts/main.js"></script>
Run Code Online (Sandbox Code Playgroud)

blu*_*fus 5

您需要按以下顺序加载 JS 文件:

<script src="jquery.js"></script>
<script src="custom-scripting.js"></script>
<script src="jquery-mobile.js"></script>
Run Code Online (Sandbox Code Playgroud)

参考:http : //jquerymobile.com/demos/1.0/docs/api/globalconfig.html