jquery step使用


title: jquery学习
date: 2019-12-09

原本在个人博客上写了一些博文,现转移到CSDN上

jquery step使用

jquery step是jquery的一个插件,用于表示进度。
step

  • step页面引入
 <link rel="stylesheet" type="text/css" stemedia="screen" href="/static/css/other/jquery-steps.css"/>
 <script type="text/javascript" src="/static/js/common/jquery-steps.js"></script>
<!-- 引入step -->
<div class="step" id="step">
   <div class="step-app">
      <ul class="step-steps text-center">

        <li>
            <a href="#step1">Theme Info</a>
        </li>
        <li>
            <a href="#step2">Models</a>
        </li>
        <li>
            <a href="#step3">Data</a>
        </li>
        <li>
            <a href="#step4">Applications</a>
        </li>

      </ul>
      <!-- step的内容 -->
      <div class="step-content">
         <div class="step-tab-panel" id="step1">
         ...
      </div>
      <div class="step-content">
         <div class="step-tab-panel" id="step2">
         ...
      </div>
      <div class="step-content">
         <div class="step-tab-panel" id="step3">
         ...
      </div>
      <div class="step-content">
         <div class="step-tab-panel" id="step4">
         ...
      </div>
<!-- step footer部分 -->
      <div class="step-footer text-right">
         <button class="btn btn-warning prev" data-direction="prev">
              Previous
          </button>
          <button class="btn btn-success finish" data-direction="finish">
               Finish
          </button>
      </div>
    </div>
</div>

以上代码中,step-footer里的按钮,可以在自己写的js中未设置的情况下执行相应的向前、向后、结束的功能,也可以根据这些class自己加相应的需要的各种功能

  • 加 未输入某些必须部分而无法下一步的功能(逻辑控制)
    logic control
$(".step").steps({

            onFinish: function () {
                alert('complete');
            },
            <!-- currentIndex为当前处于的step的标号 newIndex为下一步step标号,stepdirection可选则forword来判断是否步骤为向前 -->
            onChange: function (currentIndex, newIndex, stepDirection) {
                if (currentIndex === 0) {
                    if (stepDirection === "forward") {
                      <!-- 可在句子中加入是否输入名称的判断语句 -->
                        if ($("#nameInput").val().length == 0) {
                            alert('Please Input Theme Name!');
                            return false;
                        } else {
                            return true;
                        }
                    }
                }

                if (currentIndex === 1) {
                    if (stepDirection === "forward") {
                        if (that.themeObj.classinfo.length==1&&that.themeObj.classinfo[0].mcname==""&&that.themeObj.classinfo[0].modelsoid.length==0){
                            return true
                        } else{
                          <!-- 遍历数组,如果有一项未填,则return false,不跳入下一步 -->
                            for (i = 0; i < that.themeObj.classinfo.length; i++) {
                                if (that.themeObj.classinfo[i].mcname == "" || that.themeObj.classinfo[i].modelsoid.length == 0) {
                                    alert("Please complete the information");
                                    return false;
                                }
                            }
                        }
                        return true;
                    }
                }if (currentIndex === 2) {
                    if (stepDirection === "forward") {
                        if (that.themeObj.dataClassInfo.length==1&&that.themeObj.dataClassInfo[0].dcname==""&&that.themeObj.dataClassInfo[0].datasoid.length==0){
                            return true;
                        } else {
                            for (i = 0; i < that.themeObj.dataClassInfo.length; i++) {
                                if (that.themeObj.dataClassInfo[i].dcname == "" || that.themeObj.dataClassInfo[i].datasoid.length == 0) {
                                    alert("Please complete the information");
                                    return false;
                                }
                            }
                        }
                        return true;
                    }
                }
                if (currentIndex === 3) {
                  <!-- return true表示不判断,直接可执行下一步 -->
                    return true;
                }
            }
        });

这些便是jquery中用的step插件,element ui中也有一些好用的step功能可供选择

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值