script复制变量

colinlemoncsl 2018-04-27 03:50:13
大神们,我想让index: 0,这里的0变成一个变量,现在如果是其它数字比如3是可以的,我想让他等于$stepmax 根据数据也对,但是不知道怎么设置。

<script type="text/javascript">
var $step = $("#step");
var $index = $("#index");
$step.step({
index: 0,
time: 500,
title: ["出门申请", "部门审批", "财务审批", "门卫放行", "物品返回", "历史记录"]
});
function step_tr(id) {
var $stepmax = parseInt(document.getElementById('td15').innerText);
//alert($stepmax);
$step.toStep($stepmax);
$index.text($step.getIndex());
}

对应的jquery是这样的
!function(i){i.fn.step=function(e){var t=this,n={index:0,time:500,title:[]},s=(e=i.extend({},n,e)).title,d=s.length,u=e.time,p=t.width()/d;t.index=e.index;var a=function(){var e="";s.length>0&&(e+='<div class="ui-step-wrap"><div class="ui-step-bg"></div><div class="ui-step-progress"></div><ul class="ui-step">',i.each(s,function(i,t){e+='<li class="ui-step-item"><div class="ui-step-item-title">'+t+'</div><div class="ui-step-item-num"><span>'+(i+1)+"</span></div></li>"}),e+="</ul></div>"),t.append(e),t.find(".ui-step").children(".ui-step-item").width(p),t.toStep(t.index)};return t.toStep=function(e){var n=t.find(".ui-step").children(".ui-step-item");t.index=e,t.find(".ui-step-progress").animate({width:p*(e+1)},u,function(){i.each(n,function(t){t>e?i(this).removeClass("active"):i(this).addClass("active")})})},t.getIndex=function(){return t.index},t.nextStep=function(){t.index>d-2||(t.index++,t.toStep(t.index))},t.prevStep=function(){t.index<1||(t.index--,t.toStep(t.index))},a(),this}}(jQuery);

</script>
...全文
688 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
colinlemoncsl 2018-04-27
  • 打赏
  • 举报
回复
引用 1 楼 jslang 的回复:

        var $step = $("#step");
        var $index = $("#index");
        var $stepmax = parseInt(document.getElementById('td15').innerText);
        $step.step({
            index: $stepmax,
            time: 500,
            title: ["出门申请", "部门审批", "财务审批", "门卫放行", "物品返回", "历史记录"]
        });
        function step_tr(id) {
            //alert($stepmax);
            $step.toStep($stepmax);
            $index.text($step.getIndex());
        }
var $stepmax = parseInt(document.getElementById('td15').innerText); 把这个换成这句都可以,说明下document.getElementById('td15').innerText是个变量,我选中不通的行,结果不一样 var $stepmax = parseInt(3);
colinlemoncsl 2018-04-27
  • 打赏
  • 举报
回复
引用 1 楼 jslang 的回复:

        var $step = $("#step");
        var $index = $("#index");
        var $stepmax = parseInt(document.getElementById('td15').innerText);
        $step.step({
            index: $stepmax,
            time: 500,
            title: ["出门申请", "部门审批", "财务审批", "门卫放行", "物品返回", "历史记录"]
        });
        function step_tr(id) {
            //alert($stepmax);
            $step.toStep($stepmax);
            $index.text($step.getIndex());
        }
感谢回复,这种方法我试了不行,我是想弹出步骤图,正确应该是这样的 对应的是GridView的每行点击步骤点不一样 修改后变成了这样
天际的海浪 2018-04-27
  • 打赏
  • 举报
回复

        var $step = $("#step");
        var $index = $("#index");
        var $stepmax = parseInt(document.getElementById('td15').innerText);
        $step.step({
            index: $stepmax,
            time: 500,
            title: ["出门申请", "部门审批", "财务审批", "门卫放行", "物品返回", "历史记录"]
        });
        function step_tr(id) {
            //alert($stepmax);
            $step.toStep($stepmax);
            $index.text($step.getIndex());
        }

87,955

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧