gpt4 book ai didi

jquery - 函数适用于 Jquery 1.6.4 ,不适用于 Jquery 1.9.1

转载 作者:行者123 更新时间:2023-12-01 06:27:39 26 4
gpt4 key购买 nike

我正在使用 JQM 框架做phonegap 项目。

在这个项目中,我正在尝试制作一个向左滑动(打开)和向右滑动(关闭)的导航菜单。

这些代码在 Jquery 1.6.4 上运行良好。

但是当我将 Jquery 1.9.1 导入到我的项目中时,它不起作用。单击按钮有效,但滑动无效。

请不要告诉我继续使用 1.6.4,我需要帮助:)

这是我的功能;

    $(function(){
var menuStatus;

$("a.showMenu").click(function(){
if(menuStatus != true){
$(".ui-page-active").animate({
marginLeft: "265px",
}, 300, function(){menuStatus = true});
return false;
} else {
$(".ui-page-active").animate({
marginLeft: "0px",
}, 300, function(){menuStatus = false});
return false;
}
});

$('.pages').live("swipeleft", function(){
if (menuStatus){
$(".ui-page-active").animate({
marginLeft: "0px",
}, 300, function(){menuStatus = false});
}
});

$('.pages').live("swiperight", function(){
if (!menuStatus){
$(".ui-page-active").animate({
marginLeft: "265px",
}, 300, function(){menuStatus = true});
}
});

$("#menu li a").click(function(){
var p = $(this).parent();
if($(p).hasClass('active')){
$("#menu li").removeClass('active');
} else {
$("#menu li").removeClass('active');
$(p).addClass('active');
}
});

});

这是正文标签;

<body> 
<div id="menu">
<h3>Menu</h3>
<ul data-role="listview" data-theme="d">
<li data-icon="delete"><a href="#" data-rel="close">Close Menu</a></li>
</ul>
</div>

<div data-role="page" class="pages" id="home">
<div data-role="header">
<a href="#"class="showMenu" data-icon="grid" data-iconpos="notext" data-shadow="false" data-iconshadow="false">Menu</a>
<h1>Loreee</h1>
</div><!-- /header -->
<div data-role="content">
<p><strong>Note: You can swipe right/left to show/close menu.</strong></p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. </p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div><!-- /content -->
<div data-role="footer" data-position="fixed">
<h1>footer</h1>
</div>
</div><!-- /page -->
</body>

等待您的答复。谢谢。

最佳答案

.live 替换为 .on ,如下所示。改变

$('.pages').live("swipeleft", function(){

$(document).on("swipeleft", ".pages", function() {
//code here
});

关于jquery - 函数适用于 Jquery 1.6.4 ,不适用于 Jquery 1.9.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16302017/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com