Jquery 上一步、下一步及提交

111

复制代码
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>上一步、下一步、提交</title>
    <script src="http://apps.bdimg.com/libs/jquery/1.6.4/jquery.min.js"></script>
</head>
<body>
    <div id="box">
        <div id="sessionData" class="showOrHidden">
            <h1>sessionData</h1>
        </div>

        <div id="presidiumData" class="showOrHidden" hidden>
            <h1>presidiumData</h1>
        </div>

        <div id="hostsData" class="showOrHidden" hidden>
            <h1>hostsData</h1>
        </div>

        <div class="mui-button-row">
            <button id="lastStep" style="display:none" class="mui-btn mui-btn-primary" type="button" onclick="lastStepFunc('#box');">上一步</button>
            <button id="nextStep" class="mui-btn mui-btn-primary" type="button" onclick="nextStep('#box');">下一步</button>
            <button id="submit" style="display:none" class="mui-btn mui-btn-primary" type="button" onclick="postFunc()">&nbsp;&nbsp;</button>
        </div>

    </div>

    <script>
        var currentPage = 1;
        function lastStepFunc(id) {
            if (currentPage > 1)
                currentPage--;
            currentPageFunc(currentPage);
            var divLen = $(id).find(".showOrHidden").length;
            var Thisdiv = 0;
            for (var i = 0; i < divLen; i++) { if ($(id).find(".showOrHidden").eq(i).css("display") != "none") { Thisdiv = i; }; };
            if (Thisdiv != 0) { $(id).find(".showOrHidden").hide().eq(Thisdiv - 1).show(); };
        }
        function nextStep(id) {
            if (currentPage < 3)
                currentPage++;
            currentPageFunc(currentPage);
            var divLen = $(id).find(".showOrHidden").length;
            var Thisdiv = 0;
            for (var i = 0; i < divLen; i++) { if ($(id).find(".showOrHidden").eq(i).css("display") != "none") { Thisdiv = i; }; };
            if (Thisdiv < divLen - 1) { $(id).find(".showOrHidden").hide().eq(Thisdiv + 1).show(); };
        }
        function currentPageFunc(currentPage) {
            if (currentPage == 1) {
                $("#lastStep").hide();
                $("#nextStep").show();
                $("#submit").hide();
            } else if (currentPage == 2) {
                $("#lastStep").show();
                $("#nextStep").show();
                $("#submit").hide();
            }
            else if (currentPage == 3) {
                $("#lastStep").show();
                $("#nextStep").hide();
                $("#submit").show();
            }
        }
        function postFunc() {
            alert("点击了提交");
        }
    </script>
</body>
</html>
复制代码

 

posted @   一只桔子2233  阅读(852)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示