为什么我的代码中没有TouchSwipe jQuery插件

时间:2013-12-06 11:03:07

标签: javascript jquery html jquery-plugins

我在我的代码中使用TouchSwipe jQuery插件来检测移动鼠标,并在向左或向右显示像素移动。

我从这个地址下载了TouchSwipe jQuery插件:TouchSwipe 并在我的代码中使用......

这是我的代码:

HTML:

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link href="css/Newsfeed.css" media="screen" type="text/css" rel="stylesheet"/>
        <script src="js/jquery.js" type="text/javascript"></script>
        <script src="js/jquery.easing.1.3.min.js" type="text/javascript"></script>
        <script src="js/jquery.touchSwipe.js" type="text/javascript"></script>
        <script src="js/Newsfeed.js" type="text/javascript"></script>
    </head>
    <body>
        <div id="fullpage">
            <div class="content-part selected"></div>
                <div class="content-part selected"></div>
                <div class="content-part selected"></div>
                <div class="content-part selected"></div>
        </div>
    </body>
</html>

jQuery的:

$(document).ready(function() {
     $('#fullpage .selected').swipe( {
                swipeStatus:function(event, phase, direction, distance, duration)
                {
                    var str = "";
                    if (phase == "move")
                        str="You have moved " + distance +" px, If you leave the swipe object, the swipe will end";
                    if (phase == "end")
                        str="The swipe has ended"
                    $(this).text(str);
                },
                triggerOnTouchLeave:true,
                threshold:null
    });

});

但是这个jQuery代码无法正常工作请帮助我.... XD

1 个答案:

答案 0 :(得分:0)

你的最后一个js部分以“:”而不是“;”结束,也许这就是问题?

编辑:

我自己尝试了代码并且工作正常,你的“fullpage”和“selected”div有高度和宽度吗?

相关问题