zoukankan      html  css  js  c++  java
  • jquery实现上一页下一页

    注:文章转载于肖肖的博客;

    简单说一下思路:就是把每个页面都用position:absolute的属性使每个页面都从叠在一起。然后通过$().hide()隐藏和$().show()显示。点击当前页中的下一页,先获取这一页的index索引。然后通过加1,知道下一页的索引,先让所有页面隐藏,再让下一页显示。

    总之,获取索引,除了下一页所有页面隐藏,这样思路。

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title></title>
    <link href="css/bootstrap.min.css" rel="stylesheet"/> 
    <link href="css/font-awesome.css" rel="stylesheet"/>
    <style>

    #wizard {overflow:hidden;height:450px;margin:20px auto;570px;position:relative;-moz-border-radius:5px;-webkit-border-radius:5px;}
    #wizard .items{20000px; clear:both; position:absolute;}
    #wizard .right{float:right;}
    .lists{text-align: center;background:#EB6100;}
    #status{height:35px;padding-left:25px !important;display:inline-block;}
    #status li{float:left;color:#fff;padding:18px 30px;list-style:none;margin-right:30px;}
    #status li.active{font-weight:normal;}
    .active{background-color:#D25802;}
    .page{padding:20px 30px;570px;float:left;position:absolute;}
    .page h3{height:42px; font-size:16px; border-bottom:1px dotted #ccc; margin-bottom:20px; padding-bottom:5px}
    .page h3 em{font-size:12px; font-weight:500; font-style:normal}
    .page p{line-height:24px;}
    .page p label{font-size:14px; display:block;}
    .page p #pass{padding:0px;}
    .btn_nav{height:36px; line-height:36px; margin:20px auto;}
    .prev,.next{100px; height:45px; line-height:45px; border:1px solid #d3d3d3; cursor:pointer}

                    </style>
    </head>
    <body>
    <!--这是注册的页面-->
    <div id="main">
                <div class="logo"><img src="img/slogo.png"/>会员注册</div>
       
       
       <form action="#" method="post">
        <div class="lists">
         <ul id="status">
      <li class="active"><strong>1.</strong>设置用户名</li>
      <li><strong>2.</strong>填写账号信息</li>
      <li><strong>3.</strong>完成</li>
     </ul>
        </div>
       
     <div id="wizard">


      <div class="items">
       <div class="page">
                   <p><label>手机号:</label><input type="text" class="form-control" id="user" name="username" /></p>
                   <p><label>验证码:</label><input type="password" class="form-control" id="pass" name="password" /></p>
                    <p><label>邀请码:</label><input type="text" class="form-control" id="pass" name="invite-num" /></p>
                   <div class="btn_nav">
                      <input type="button" class="next right" value="下一步&raquo;" />
                   </div>
                </div>
       <div class="page">
                   <h3>填写联系信息<br/><em>请告诉我们您的联系方式。</em></h3>
                   <p><label>E-mail:</label><input type="text" class="form-control" name="email" /></p>
                   <p><label>QQ:</label><input type="text" class="form-control" name="qq" /></p>
                   <div class="btn_nav">
                      <input type="button" class="prev" style="float:left" value="&laquo;上一步" />
                      <input type="button" class="next right" value="下一步&raquo;" />
                   </div>
                </div>
       <div class="page">
                   <h3>完成注册<br/><em>点击确定完成注册。</em></h3>
                   <h4>马卡龙欢迎您!</h4>
                   <p>请点击“确定”按钮完成注册。</p>
                   <br/>
                   <br/>
                   <br/>
                   <div class="btn_nav">
                      <input type="button" class="prev" style="float:left" value="&laquo;上一步" />
                      <input type="button" class="next right" id="sub" value="确定" />
                   </div>
                </div>
      </div>
     </div>
    </form>
    </div>


    <script src="js/jQuery-1.9.1.min.js"></script>

    <script>

    $(function(){
    $(".page").hide();          //所有页面都隐藏
    $("#status li").removeClass("active");      //让导航条都不添加样式
    $(".items .page").eq(0).show();                 //默认第一个页面显示
    $("#status li").eq(0).addClass("active");    //第一个导航加样式
    //下一步
         $(".next.right").click(function(){
        var num=$(this).parent().parent().index()+1;   //当前这个page的索引加1,指的是下一页
        $(".page").hide();                                 //所有页面都隐藏
        $(".items .page").eq(num).show();       //下一个页面显示
        $("#status li").removeClass("active");     //所有导航条都清除样式
        $("#status li").eq(num).addClass("active");   //当前页面的那个导航添加样式
        
         });
         
         //上一步
         $(".prev").click(function(){
            var num=$(this).parent().parent().index()-1;
            $(".page").hide();
        $(".items .page").eq(num).show();
        $("#status li").removeClass("active");
        $("#status li").eq(num).addClass("active");
         });
         
         });
    </script>
    </body>
    </html>

  • 相关阅读:
    利用SuperMap Deskpro进行Peking 54到WGS84的转换
    远程序列化xml文件(可用于自动更新程序中版本号的比较,更新文件的读取等)
    [转]C#导出到EXCEL
    [转]常用数学公式
    CLR Via C#系列学习笔记之委托
    黑马程序员C#语言中的三种循环:while 循环、dowhile 循环、for 循环。
    .net2005中GridView或者Datalist等超級流行的分頁
    Array.splice()删除数组中重复的数据
    .net中常需对文件夹以及常用的操作方法
    文件的上传下载示例
  • 原文地址:https://www.cnblogs.com/-CLAY-/p/6707228.html
Copyright © 2011-2022 走看看