如何用js做翻页效果

JavaScript08

如何用js做翻页效果,第1张

参考代码如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >

    <head>

    <title></title>

    <script type="text/javascript" language="javascript" src="http://www.codefans.net/ajaxjs/jquery-1.4.2.min.js"></script>

    <script type="text/javascript" language="javascript">

    $(function() {

    $("#right").click(function() {

    var roll = $("<div></div>", { css: { position: "absolute", border: "solid 1px #999", left:    "806px", top: "10px", height: "494px", width: "1px", background:                     "#fff"}}).appendTo($("#book").parent())

    $(roll).animate({

    left: "10px",

    width: "398px"

    }, 1000, function() {

    $("#left").css({"background":"#fff"})

    $(roll).fadeOut(300, function() {

    $(roll).remove()

    })

    })

    })

    })

    </script>

    </head>

    <body style="padding:5pxmargin:0">

    <div id="book" style="width:797pxheight:494pxbackground:#cccborder:solid 6px #ccc">

    <div id="left" style="width:398pxheight:494pxfloat:leftbackground:url(http://www.codefans.net/jscss/demoimg/201011/PLh.png) no-repeat top leftcursor:pointer"></div>

    <div id="right" style="width:398pxheight:494pxfloat:leftbackground:#fffcursor:pointermargin-left:1pxtext-align:right"><p style="margin-top:470pxfont-size:12pxcolor:#999">点这翻页  </p></div>

    </div>

    </body>

    </html>

//声明一个为0的变量做记录值

doucument.body.addEvenetListener('touchstart',function(e){

//记录下按下时的e.touches[0].clientY或者e.touches[0].pageY

})

document.body.addEventListener('touchmove',function(e){

//获取当前e.touches[0].clientY或者e.touches[0].pageY 并且与之前记录的值比较 当前值大于之前值的话就可以判断当前动作是在向上滑动 然后做翻页的操作即可

})

如果用现成的js框架做的话 有一个叫quo.js的框架非常不错

首次展示是怎么做的?(ajax还是页面直接跳转)

展示时记录当前是第几篇(这里的一篇对应上面的7页)

总篇数小于2的就要显示<<和>>了

点击>>这个时,篇数加1,并查询对应的数据展示出来。

最好,把你目前这里的代码贴出来