window.$stepCtrl = { elementData:{}, targetContents:{}, onload:function(){ var elements = document.getElementsByClassName('laz-steps'); try{ for (var i in elements){ var element = elements[i]; if (is_element(element)){ var key = element.getAttribute("laz-key"); var idx = element.getAttribute('laz-step-index'); if (!this.elementData[key]) { this.elementData[key] = { "index-now":-1, elements:{} }; } this.elementData[key]['elements'][parseInt(idx)] = element; if (idx == 0){ this.nextStep(key); } } } }catch (e){ console.warn(e); } }, nextStep:function(key){ try{ var idx = this.elementData[key]['index-now']; if (idx != -1){ this.elementData[key]['elements'][idx].setAttribute("laz-active","hide"); } idx ++; this.elementData[key]['elements'][idx].setAttribute("laz-active","show"); this.elementData[key]['index-now'] = idx; }catch (e){ console.warn(e); } }, lastStep:function(key){ try{ var idx = this.elementData[key]['index-now']; if (idx != -1){ this.elementData[key]['elements'][idx].setAttribute("laz-active","hide"); } if (idx > 0){ idx --; this.elementData[key]['elements'][idx].setAttribute("laz-active","show"); this.elementData[key]['index-now'] = idx; } }catch (e){ console.warn(e); } } };
<div class="laz-steps" laz-step-index="0" laz-key="register"> <form method="post" laz-action="" laz-call="step1" onsubmit="return LazFormCheck(this);"> <div class="std-form-group"> <label>邀请人手机号</label> <input type="text" name="inviter" class="std-form-control"/> </div> <button type="submit" class="std-btn std-btn-warning">下一步</button> </form> </div>