gpt4 book ai didi

javascript - 未捕获的类型错误 $(...).swipe 不是函数

转载 作者:行者123 更新时间:2023-11-29 10:39:20 27 4
gpt4 key购买 nike

我正在尝试在博客中制作一个可滑动的菜单,这是我的代码:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript" src="https://www.googledrive.com/host/0B2Iusn9ixPQ2cFFldHoweXRsWms"></script>


<script type="text/javascript">
$(window).load(function(){
$("[data-toggle]").click(function() {
var toggle_el = $(this).data("toggle");
$(toggle_el).toggleClass("open-sidebar");
});
$(".swipe-area").swipe({
swipeStatus:function(event, phase, direction, distance, duration, fingers)
{
if (phase=="move" &amp;&amp; direction =="right") {
$(".container").addClass("open-sidebar");
return false;
}
if (phase=="move" &amp;&amp; direction =="left") {
$(".container").removeClass("open-sidebar");
return false;
}
}
});
});

</script>

我在“$(”.swipe-area”).swipe({": uncaught typeerror $(...).swipe is not a function 处收到此错误

请帮助,谢谢

最佳答案

试试这个

<html>
<head>

<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script>
$(document).on("pagecreate","#pageone",function(){
$("p").on("swipe",function(){
$(this).hide();
});
});
</script>
</head>
<body>

<div data-role="page" id="pageone">
<div data-role="main" class="ui-content">
<p>If you swipe me, I will disappear.</p>
<p>Swipe me away!</p>
<p>Swipe me too!</p>
</div>
</div>

</body>
</html>

更新 - 意外的 token

您的代码中存在语法错误

swipeStatus:function(event, phase, direction, distance, duration, fingers)

正确的语法 - 在下面的方式中,您可以定义swipeStatus一个函数

var swipeStatus  = function(event, phase, direction, distance, duration, fingers)

关于javascript - 未捕获的类型错误 $(...).swipe 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31771227/

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