jquery 使用自适应步骤条

效果图

在这里插入图片描述

先看step.css

/*common css*/
.stepPage{
    display:none;
    height:100%;
}
.stepCont{
    width:100%;
}
.ystep-container {
    font-family: "Helvetica Neue",Helvetica,"Hiragino Sans GB","Wenquanyi Micro Hei","Microsoft Yahei",Arial,sans-serif;
    display: inline-block;
    position: relative;
    color: #000;
    margin: 20px;
}
.ystep-container ul {
    list-style: none;
}
.ystep-container ul,.ystep-container li,.ystep-container p {
    margin: 0;
    padding: 0;
}

/*size css*/
.ystep-lg {
    /*width: 700px;*/
    width:100%;
    height: 60px;
    font-size: 18px;
    /*left: 15%;*/
    line-height: .3;
}

/*large size css*/
.ystep-lg .ystep-container-steps {
    position: absolute;
    top: 2px;
    cursor: pointer;
    z-index: 10;
}
.ystep-lg li {
    float: left;
    width: 100px;
    /*height: 85px;*/
    margin-right: 100px;
    line-height: 23px;
    box-sizing: border-box;

}

.ystep-lg .ystep-progress {
    width: 400px;
    height: 3px;
    position: absolute;
    top: 34px;
    left: 15px;
    float: left;
    margin-right: 10px;
    overflow: hidden;
    background: #C0C4CC;
}
.ystep-lg .ystep-progress-bar {
    width: 400px;
    height: 20px;
    background: #e4e4e4;
    display: inline-block;
    float: left;
}
.ystep-lg .ystep-progress-highlight {
    height: 20px;
    display: block;
}

/*blue css*/
.ystep-blue .ystep-step-done {
    /*background-image: url("./images/pointes_blue.png");
    background-repeat: no-repeat;*/
}
.ystep-blue .ystep-step-undone {
    /*background-image: url("./images/pointes_blue.png");
    background-repeat: no-repeat;
    color: #9c9a9b;*/
}
.ystep-blue .ystep-step-active {
    /*background-image: url("./images/pointes_blue.png");
    background-repeat: no-repeat;*/
    color: #3276b1;
}
.ystep-blue .ystep-progress-highlight {
    background: #60baff;
}
/*按钮样式*/
.ystep {
    padding: 20px;
    /*min-width: 1114px;*/
}
.step-button{
    position: relative;
    /*top: -85px;*/
}
.step-button button{
    margin: 15px;
}
.stepIcon{

}
.ystep-lg .ystep-step-done .stepIcon{
    border: 1px solid #2D5FAD;
    border-radius: 20px;
    width: 20px;
    height: 20px;
    display: block;
    text-align: center;
    margin-top: 22px;
    margin-left: 8px;
    color: transparent;
    background:#fff url(images/duihao.png) no-repeat 1px 4px;
    background-size: 80%;
}

.ystep-lg .ystep-step-undone .stepIcon{
    border: 1px solid #909399;
    border-radius: 20px;
    width: 20px;
    height: 20px;
    display: block;
    text-align: center;
    margin-top: 22px;
    margin-left: 8px;
    color:#909399;
    background: #fff;
}
.ystep-lg .ystep-step-active .stepIcon{
    border: 1px solid #303133;
    border-radius: 20px;
    width: 20px;
    height: 20px;
    display: block;
    text-align: center;
    margin-top: 22px;
    margin-left: 8px;
    color:#303133;
    background: #fff;
}
.ystep-container .descriptionHeader{
    width: 157px;
    margin-top: 5px;
    font-size: 14px;


}
.ystep-container .description{
    width: 120px;
    font-size: 10px;
}



/*****************************竖向步骤条设置**************************/

.stepY .ystep-lg {
    width:160px;
    height: 60px;
    font-size: 18px;
    line-height: .3;
    float: left;
}
.stepY .pageCont{
    width: calc(100% - 210px);
    float: right;
}

.stepY .ystep-lg li {
    width: 150px;
    line-height: 23px;
    box-sizing: border-box;

}

.stepY .ystep-lg .ystep-progress {
    height: 400px;
    width: 3px;
    position: absolute;
    top: 34px;
    left: 17px;
    float: left;
    margin-right: 10px;
    overflow: hidden;
    background: #C0C4CC;
}
.stepY .ystep-lg .ystep-progress-bar {
    width:20px;
    height:400px;
    background: #e4e4e4;
    display: inline-block;
    float: left;
}
.stepY .ystep-lg .ystep-progress-highlight {
    width: 20px;
    display: block;
}

.stepY .ystep-container .descriptionHeader{
    width: 157px;
    margin-top: -22px;
    font-size: 14px;
    float: left;
    margin-left: 35px;

}
.stepY .ystep-container .description{
    width: 120px;
    font-size: 10px;
    float: left;
    margin-left: 35px;
}

.clearfix:after{
       content:"";
       height:0;
       line-height:0;
       display:block;
       visibility:hidden;
       clear:both;
     }

/*-----------------箭头步骤条------------------*/

.jiantou li{
    margin-right:0px;
    background: #F0F2F5;
}
.jiantou .descriptionHeader{
    float: right;
    width: 120px;
    margin-top: -30px;
    font-size: 14px;
}

.jiantou .tubiao{
    font-size: 30px;
    float: right;
    line-height: 20px;
}

.jiantou .ystep-lg .ystep-step-done .stepIcon{
    border: 1px solid #2D5FAD;
    border-radius: 20px;
    width: 20px;
    height: 20px;
    display: block;
    text-align: center;
    margin-top: 10px;
    margin-bottom: 10px;
    margin-left: 8px;
    color: transparent;
    background:#fff url(images/duihao.png) no-repeat 1px 4px;
    background-size: 80%;
}
.jiantou .ystep-lg .ystep-step-done .descriptionHeader{
    color: #2D5FAD;
}
.jiantou .ystep-lg .ystep-step-undone .stepIcon{
    border: 1px solid #909399;
    border-radius: 20px;
    width: 20px;
    height: 20px;
    display: block;
    text-align: center;
    margin-top: 10px;
    margin-bottom: 10px;
    margin-left: 8px;
    color:#909399;
    background: #F0F2F5;
}
.jiantou .ystep-lg .ystep-step-active .stepIcon{
    border: 1px solid #303133;
    border-radius: 20px;
    width: 20px;
    height: 20px;
    display: block;
    text-align: center;
    margin-top: 10px;
    margin-bottom: 10px;
    margin-left: 8px;
    color:#303133;
    background: #F0F2F5;
}

step.js

/***
 *
 var step3 = new SetStep({
        content: '.stepCont3',
        steps: ['1', '2', '3', '4', '5','6'],           //步骤标题
        descriptionHeader: ['步骤一', '步骤二', '步骤三', '步骤四', '步骤五','步骤五1'],//步骤标题
        description: ['', '', '', '', '',''],   //步骤文本
        //pageClass:'',//分页的类或则id
        curStep: 1, //当前显示第几页
        animating: false,
        showBtn: true, //是否生成上一步下一步操作按钮
        clickAble: true, //是否可以通过点击进度条的节点操作进度
        onLoad: function() {

        }
    })

 //下一步
 step3.nextBtn.click();
 //上一步
 step3.prevBtn.click();
 */

function extend(obj1, obj2) {
    for(var attr in obj2) {
        obj1[attr] = obj2[attr];
    }
}

function SetStep(arg) {
    this.body = document.body;
    this.opt = {
        skin:arg.skin?? 1,
        show: arg.show??false,
        content: arg.content??'.stepCont',
        pageCont: arg.pageCont??'.pageCont',
        imgWidth: arg.imgWidth??20,
        stepContainerMar: arg.stepContainerMar??20,
        nextBtn: arg.nextBtn??'.nextBtn',
        prevBtn: arg.prevBtn??'.prevBtn',
        steps: arg.steps??['1', '2', '3', '4', '5','6'],
        descriptionHeader: arg.descriptionHeader??['步骤一', '步骤二', '步骤三', '步骤四', '步骤五'],
        description: arg.description??['', '', '', '', ''],
        //pageClass:'',//分页的类或则id
        stepCounts: arg.stepCounts??10, //总共的步骤数
        curStep: arg.curStep??1, //当前显示第几页
        animating: arg.animating??false,
        showBtn: arg.showBtn??true, //是否生成上一步下一步操作按钮
        clickAble: arg.clickAble??true, //是否可以通过点击进度条的节点操作进度
        onLoad:arg.onLoad??function() {

        }
    };

    var options = $.extend({}, this.opt, arg);

    switch(options.skin) {
        case 1:
            this.init(arg);
            break;
        case 2:
            $(options.content).addClass("stepY");
            this.initY(arg);
            break;
        case 3:
            $(options.content).addClass("jiantou");
            this.initJanTou(arg);
            break;
        default:
            this.init(arg);
    }

}

//初始化 生成页面的进度条和按钮  箭头
SetStep.prototype.initJanTou = function(arg) {
    var _that = this;
    extend(this.opt, arg);
    this.opt.stepCounts = this.opt.steps.length;
    this.content = $(this.opt.content);
    this.pageCont = this.content.find(this.opt.pageCont);
    var w_con = $(this.content).width();
    var w_li = (w_con - this.opt.stepContainerMar * 2) / this.opt.stepCounts / 2;

    var stepContainer = this.content.find('.ystep-container');

    this.stepContainer = stepContainer;
    var stepsHtml = $("<ul class='ystep-container-steps'></ul>");
    var stepDisc = "<li class='ystep-step ystep-step-undone'></li>";
    var stepP = $("<div class='ystep-progress'>" +
        "<p class='ystep-progress-bar'><span class='ystep-progress-highlight' style='width:0%'></span></p>" +
        "</div>");
    var stepButtonHtml = $("<div class='step-button'><button type='button' class='btn btn-default prevBtn' id='prevBtn' class='prevBtn'>上一步</button>" +
        "<button type='button' class='btn btn-default nextBtn' id='nextBtn' class='nextBtn'>下一步</button></div>");
    stepP.css('width', w_li * 2 * (this.opt.stepCounts - 1));
    stepP.find('.ystep-progress-bar').css('width', w_li * 2 * (this.opt.stepCounts - 1))
    for(var i = 0; i < this.opt.stepCounts; i++) {
        if(i == 0) {
            var _s = $(stepDisc).html('<span class="stepIcon">' + this.opt.steps[i] + '</span><span class="descriptionHeader">' + this.opt.descriptionHeader[i] + '<i class="fa fa-angle-right tubiao"></i></span>').addClass('')
        } else {
            var _s = $(stepDisc).html('<span class="stepIcon">' + this.opt.steps[i] + '</span><span class="descriptionHeader">' + this.opt.descriptionHeader[i] + '<i class="fa fa-angle-right tubiao"></i></span>')
        }
        stepsHtml.append(_s);
    }
    stepsHtml.find('li').css('width', w_li * 2).css("padding-left", "60px")
    stepContainer.append(stepsHtml).append(stepP);

    stepContainer.css('left', (w_con - stepP.width() - this.opt.imgWidth - 10 - this.opt.stepContainerMar * 2) / 2 - 120)
    stepContainer.css('height', stepsHtml.height() - 20);

    this.content.css('overflow', 'hidden')
    this.setProgress(this.stepContainer, this.opt.curStep, this.opt.stepCounts)
    //判断参数 是否显示按钮 并绑定点击事件
    if(this.opt.showBtn) {
        this.content.append(stepButtonHtml)
        this.prevBtn = this.content.find(this.opt.prevBtn)
        this.nextBtn = this.content.find(this.opt.nextBtn)
        this.prevBtn.on('click', function() {
            // if($(this).hasClass('handleAble')){
            if($(_that).attr('disabled') || _that.opt.animating) {
                return false;
            } else {
                _that.opt.animating = true;
                _that.opt.curStep--;
                _that.setProgress(_that.stepContainer, _that.opt.curStep, _that.opt.stepCounts)
            }
        })
        this.nextBtn.on('click', function() {
            // if($(this).hasClass('handleAble')){
            if($(_that).attr('disabled') || _that.opt.animating) {
                return false;
            } else {
                _that.opt.animating = true;
                _that.opt.curStep++;
                _that.setProgress(_that.stepContainer, _that.opt.curStep, _that.opt.stepCounts)
            }
        })
    }
    //判断时候可点击进度条 并绑定点击事件
    if(this.opt.clickAble) {
        stepsHtml.find('li').on('click', function() {
            _that.opt.curStep = $(this).index() + 1;
            _that.setProgress(_that.stepContainer, _that.opt.curStep, _that.opt.stepCounts)
        })
    }
    $(window).resize(function() {
        var w_con = $(_that.content).width();
        var w_li = w_con / _that.opt.stepCounts / 2;
        stepP.css('width', w_li * 2 * (_that.opt.stepCounts - 1));
        stepP.find('.ystep-progress-bar').css('width', w_li * 2 * (_that.opt.stepCounts - 1))
        stepsHtml.find('li').css('width', w_li * 2).css("padding-left", "60px")
        // stepContainer.css('left',(w_con-stepP.width()-_that.opt.imgWidth-10-_that.opt.stepContainerMar*2)/2)
        stepContainer.css('left', (w_con - stepP.width() - _that.opt.imgWidth - 10 - _that.opt.stepContainerMar * 2) / 2 - 120)
    })
}

//初始化 生成页面的进度条和按钮x
SetStep.prototype.init = function(arg) {
    var _that = this;
    extend(this.opt, arg);
    this.opt.stepCounts = this.opt.steps.length;
    this.content = $(this.opt.content);
    this.pageCont = this.content.find(this.opt.pageCont);
    var w_con = $(this.content).width();
    var w_li = (w_con - this.opt.stepContainerMar * 2) / this.opt.stepCounts / 2;

    var stepContainer = this.content.find('.ystep-container');

    this.stepContainer = stepContainer;
    var stepsHtml = $("<ul class='ystep-container-steps'></ul>");
    var stepDisc = "<li class='ystep-step ystep-step-undone'></li>";
    var stepP = $("<div class='ystep-progress'>" +
        "<p class='ystep-progress-bar'><span class='ystep-progress-highlight' style='width:0%'></span></p>" +
        "</div>");
    var stepButtonHtml = $("<div class='step-button'><button type='button' class='btn btn-default prevBtn' id='prevBtn' class='prevBtn'>上一步</button>" +
        "<button type='button' class='btn btn-default nextBtn' id='nextBtn' class='nextBtn'>下一步</button></div>");
    stepP.css('width', w_li * 2 * (this.opt.stepCounts - 1));
    stepP.find('.ystep-progress-bar').css('width', w_li * 2 * (this.opt.stepCounts - 1))
    for(var i = 0; i < this.opt.stepCounts; i++) {
        if(i == 0) {
            var _s = $(stepDisc).html('<span class="stepIcon">' + this.opt.steps[i] + '</span><p class="descriptionHeader">' + this.opt.descriptionHeader[i] + '</p><div class="description">' + this.opt.description[i] + '</div>').addClass('')
        } else {
            var _s = $(stepDisc).html('<span class="stepIcon">' + this.opt.steps[i] + '</span><p class="descriptionHeader">' + this.opt.descriptionHeader[i] + '</p><div class="description">' + this.opt.description[i] + '</div>')
        }
        stepsHtml.append(_s);
    }
    stepsHtml.find('li').css('width', '40px').css('marginRight', w_li * 2 - 40)
    stepContainer.append(stepsHtml).append(stepP);

    stepContainer.css('left', (w_con - stepP.width() - this.opt.imgWidth - 10 - this.opt.stepContainerMar * 2) / 2)
    stepContainer.css('height', stepsHtml.height() - 25);

    this.content.css('overflow', 'hidden')
    this.setProgress(this.stepContainer, this.opt.curStep, this.opt.stepCounts)
    //判断参数 是否显示按钮 并绑定点击事件
    if(this.opt.showBtn) {
        this.content.append(stepButtonHtml)
        this.prevBtn = this.content.find(this.opt.prevBtn)
        this.nextBtn = this.content.find(this.opt.nextBtn)
        this.prevBtn.on('click', function() {
            // if($(this).hasClass('handleAble')){
            if($(_that).attr('disabled') || _that.opt.animating) {
                return false;
            } else {
                _that.opt.animating = true;
                _that.opt.curStep--;
                _that.setProgress(_that.stepContainer, _that.opt.curStep, _that.opt.stepCounts)
            }
        })
        this.nextBtn.on('click', function() {
            // if($(this).hasClass('handleAble')){
            if($(_that).attr('disabled') || _that.opt.animating) {
                return false;
            } else {
                _that.opt.animating = true;
                _that.opt.curStep++;
                _that.setProgress(_that.stepContainer, _that.opt.curStep, _that.opt.stepCounts)
            }
        })
    }
    //判断时候可点击进度条 并绑定点击事件
    if(this.opt.clickAble) {
        stepsHtml.find('li').on('click', function() {
            _that.opt.curStep = $(this).index() + 1;
            _that.setProgress(_that.stepContainer, _that.opt.curStep, _that.opt.stepCounts)
        })
    }
    $(window).resize(function() {
        var w_con = $(_that.content).width();
        var w_li = w_con / _that.opt.stepCounts / 2;
        stepP.css('width', w_li * 2 * (_that.opt.stepCounts - 1));
        stepP.find('.ystep-progress-bar').css('width', w_li * 2 * (_that.opt.stepCounts - 1))
        stepsHtml.find('li').css('width', '40px').css('marginRight', w_li * 2 - 40)
        stepContainer.css('left', (w_con - stepP.width() - _that.opt.imgWidth - 10 - _that.opt.stepContainerMar * 2) / 2)
    })
}

//初始化 生成页面的进度条和按钮Y
SetStep.prototype.initY = function(arg) {
    var _that = this;
    extend(this.opt, arg);
    this.opt.stepCounts = this.opt.steps.length;
    this.content = $(this.opt.content);
    this.pageCont = this.content.find(this.opt.pageCont);
    var w_con = $(this.content).width();
    var h_con = $(this.content).height();
    console.log(h_con, w_con)
    var w_li = (w_con - this.opt.stepContainerMar * 2) / this.opt.stepCounts / 2 - 60;
    var h_li = (h_con - this.opt.stepContainerMar * 2) / this.opt.stepCounts / 2;
    var stepContainer = this.content.find('.ystep-container');
    this.stepContainer = stepContainer;
    var stepsHtml = $("<ul class='ystep-container-steps'></ul>");
    var stepDisc = "<li class='ystep-step ystep-step-undone'></li>";
    var stepP = $("<div class='ystep-progress'>" +
        "<p class='ystep-progress-bar'><span class='ystep-progress-highlight' style='height:0%'></span></p>" +
        "</div>");
    var stepButtonHtml = $("<div class='step-button'><button type='button' class='btn btn-default prevBtn' id='prevBtn' class='prevBtn'>上一步</button>" +
        "<button type='button' class='btn btn-default nextBtn' id='nextBtn' class='nextBtn'>下一步</button></div>");
    stepP.css('height', w_li * 2 * (this.opt.stepCounts - 1));
    stepP.find('.ystep-progress-bar').css('height', w_li * 2 * (this.opt.stepCounts - 1))
    for(var i = 0; i < this.opt.stepCounts; i++) {
        if(i == 0) {
            var _s = $(stepDisc).html('<span class="stepIcon">' + this.opt.steps[i] + '</span><p class="descriptionHeader">' + this.opt.descriptionHeader[i] + '</p><div class="description">' + this.opt.description[i] + '</div>').addClass('')
        } else {
            var _s = $(stepDisc).html('<span class="stepIcon">' + this.opt.steps[i] + '</span><p class="descriptionHeader">' + this.opt.descriptionHeader[i] + '</p><div class="description">' + this.opt.description[i] + '</div>')
        }
        stepsHtml.append(_s);
    }
    stepsHtml.find('li').css('height', '40px').css('marginBottom', w_li * 2 - 40)
    stepContainer.append(stepsHtml).append(stepP);

    stepContainer.css('height', stepsHtml.height() - 25);

    //this.content.css('overflow','hidden')
    this.setProgressY(this.stepContainer, this.opt.curStep, this.opt.stepCounts)
    //判断参数 是否显示按钮 并绑定点击事件
    if(this.opt.showBtn) {
        this.content.append(stepButtonHtml)
        this.prevBtn = this.content.find(this.opt.prevBtn)
        this.nextBtn = this.content.find(this.opt.nextBtn)
        this.prevBtn.on('click', function() {
            // if($(this).hasClass('handleAble')){
            if($(_that).attr('disabled') || _that.opt.animating) {
                return false;
            } else {
                _that.opt.animating = true;
                _that.opt.curStep--;
                _that.setProgressY(_that.stepContainer, _that.opt.curStep, _that.opt.stepCounts)
            }
        })
        this.nextBtn.on('click', function() {
            // if($(this).hasClass('handleAble')){
            if($(_that).attr('disabled') || _that.opt.animating) {
                return false;
            } else {
                _that.opt.animating = true;
                _that.opt.curStep++;
                _that.setProgressY(_that.stepContainer, _that.opt.curStep, _that.opt.stepCounts)
            }
        })
    }
    //判断时候可点击进度条 并绑定点击事件
    if(this.opt.clickAble) {
        stepsHtml.find('li').on('click', function() {
            _that.opt.curStep = $(this).index() + 1;
            _that.setProgressY(_that.stepContainer, _that.opt.curStep, _that.opt.stepCounts)
        })
    }
}

//设置进度条y
SetStep.prototype.setProgressY = function(n, curIndex, stepsLen) {
    var _that = this;
    //获取当前容器下所有的步骤
    var $steps = $(n).find("li");
    var $progress = $(n).find(".ystep-progress-highlight");
    //判断当前步骤是否在范围内
    if(1 <= curIndex && curIndex <= $steps.length) {
        //更新进度
        var scale = "%";
        scale = Math.round((curIndex - 1) * 100 / ($steps.length - 1)) + scale;
        $progress.animate({
            height: scale
        }, {
            speed: 1000,
            done: function() {
                //移动节点
                $steps.each(function(j, m) {
                    var _$m = $(m);
                    var _j = j + 1;
                    if(_j < curIndex) {
                        _$m.attr("class", "ystep-step-done");
                    } else if(_j === curIndex) {
                        _$m.attr("class", "ystep-step-active");
                    } else if(_j > curIndex) {
                        _$m.attr("class", "ystep-step-undone");
                    }
                })
                if(_that.opt.showBtn) {
                    if(curIndex == 1) {
                        _that.prevBtn.attr('disabled', 'true')
                        _that.nextBtn.removeAttr('disabled')
                    } else if(curIndex == stepsLen) {
                        _that.prevBtn.removeAttr('disabled')
                        _that.nextBtn.attr('disabled', 'true')
                    } else if(1 < curIndex < stepsLen) {
                        _that.prevBtn.removeAttr('disabled')
                        _that.nextBtn.removeAttr('disabled')
                    }
                }
                _that.checkPage(_that.pageCont, _that.opt.curStep, _that.opt.stepCounts)
                _that.opt.animating = false;
            }
        });
    } else {
        return false;
    }
}

//设置进度条x
SetStep.prototype.setProgress = function(n, curIndex, stepsLen) {
    var _that = this;
    //获取当前容器下所有的步骤
    var $steps = $(n).find("li");
    var $progress = $(n).find(".ystep-progress-highlight");
    //判断当前步骤是否在范围内
    if(1 <= curIndex && curIndex <= $steps.length) {
        //更新进度
        var scale = "%";
        scale = Math.round((curIndex - 1) * 100 / ($steps.length - 1)) + scale;
        $progress.animate({
            width: scale
        }, {
            speed: 1000,
            done: function() {
                //移动节点
                $steps.each(function(j, m) {
                    var _$m = $(m);
                    var _j = j + 1;
                    if(_j < curIndex) {
                        _$m.attr("class", "ystep-step-done");
                    } else if(_j === curIndex) {
                        _$m.attr("class", "ystep-step-active");
                    } else if(_j > curIndex) {
                        _$m.attr("class", "ystep-step-undone");
                    }
                })
                if(_that.opt.showBtn) {
                    if(curIndex == 1) {
                        _that.prevBtn.attr('disabled', 'true')
                        _that.nextBtn.removeAttr('disabled')
                    } else if(curIndex == stepsLen) {
                        _that.prevBtn.removeAttr('disabled')
                        _that.nextBtn.attr('disabled', 'true')
                    } else if(1 < curIndex < stepsLen) {
                        _that.prevBtn.removeAttr('disabled')
                        _that.nextBtn.removeAttr('disabled')
                    }
                }
                _that.checkPage(_that.pageCont, _that.opt.curStep, _that.opt.stepCounts)
                _that.opt.animating = false;
            }
        });
    } else {
        return false;
    }
}
//改变 分页显示
SetStep.prototype.checkPage = function(pageCont, curStep, steps) {
    for(var i = 1; i <= steps; i++) {
        if(i === curStep) {
            pageCont.find('#page' + i).css("display", "block");
        } else {
            pageCont.find('#page' + i).css("display", "none");
        }
    }
}

以下是html部分

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="./step.css">
    <script src="http://www.jq22.com/jquery/jquery-1.10.2.js"></script>
    <script type="text/javascript" src="./step.js"></script>
    <script type="text/javascript" src="./id.js"></script>
</head>
<body>

<!-- 菜单及分页容器-->
<div class="stepCont stepCont3">
    <!-- 菜单导航显示-->
    <div class='ystep-container ystep-lg ystep-blue'></div>
    <!-- 分页容器 如果没有可以不用-->
    <div class="pageCont">
        <div id="page1" class="stepPage">
            <h2>我是第一页的内容</h2>
        </div>
        <div id="page2" class="stepPage">
            <h2>我是第二页的内容</h2>
        </div>
        <div id="page3" class="stepPage">
            <h2>我是第三页的内容</h2>
        </div>
        <div id="page4" class="stepPage">
            <p>我是第四页的内容</p>
        </div>
        <div id="page5" class="stepPage">
            <p>我是第五页的内容</p>
        </div>
        <div id="page6" class="stepPage">
            <p>我是第六页的内容</p>
        </div>
    </div>
</div>

<script>
    let option = {
        content: '.stepCont3',
        steps: ['1', '2', '3', '4', '5','6'],           //步骤标题
        descriptionHeader: ['步骤一', '步骤二', '步骤三', '步骤四', '步骤五','步骤五1'],//步骤标题
        description: ['', '', '', '', '',''],   //步骤文本
        //pageClass:'',//分页的类或则id
        curStep: 1, //当前显示第几页
        animating: false,
        showBtn: true, //是否生成上一步下一步操作按钮
        clickAble: false, //是否可以通过点击进度条的节点操作进度
        onLoad: function() {

        }
    }

    var step = new SetStep(option);
    setInterval(()=>{
        console.log('我默认点击了下一步');
        step.nextBtn.click();
    },2000)
</script>
</body>
</html>
  • 3
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值