我无法弄清楚为什么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) 不知道这里有什么问题.所有其他代码工作正常并且已经永远但现在我只是尝试将另一个类添加到您单击的元素并且该函数仍然正常工作它似乎忽略了我的.addClass().
$('.item-main-section, .item-status').click( function () {
var slideHeight = $(this).parent().children('.item-slide-section').height();
//Not Doing Anything
if ($('item-slide-section').hasClass('current-open')) {
$('item-slide-section').removeClass('current-open');
}
$(this).parent().children('item-slide-section').addClass('current-open');
//Not Doing Anything ^^^^
if ($(this).parent().height() > 50) {
$(this).parent().animate({height: '50px'}, 300);
$(this).parent().children('item-slide-section').animate({bottom: '0px'}, 300);
} else {
$(this).parent().animate({height: slideHeight + 50 + 'px'}, 300);
$(this).parent().children('item-slide-section').animate({bottom: slideHeight - 5 + 'px'}, 300);
$(this).parent().siblings('.item-wrapper').animate({height: '50px'}, 300);
$(this).parent().siblings('.item-wrapper').children('item-slide-section').animate({bottom: '0px'}, 300);
}
});
Run Code Online (Sandbox Code Playgroud)