Layui的Tab选项卡的记忆刷新

<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief" >
  <ul class="layui-tab-title" style="background-color: #393D49;color: white;color:white;height: 47px;text-align:center;">
    <li class="tyy">Bootstrap表格</li>
    <li class="b" >Layui商品树</li>
  </ul>
  <div class="layui-tab-content">
    <div class="layui-tab-item layui-show a">
        {include file="inc/index" /}

    </div>
    <div class="layui-tab-item">
        {include file="inc/tree" /}
    </div>
  </div>
</div>
  $(".layui-tab-title li").click(function(){
    //获取当前选项卡
    var picTabNum = $(this).index();
    //存入sessionstrage
    sessionStorage.setItem("picTabNum",picTabNum);
  });
  $(function(){
    var getPicTabNum = sessionStorage.getItem("picTabNum");
    // 取出 放入eq
    $(".layui-tab-title li").eq(getPicTabNum).addClass("layui-this").siblings().removeClass("layui-this");
    $(".layui-tab-content>div").eq(getPicTabNum).addClass("layui-show").siblings().removeClass("layui-show");
  })

为您推荐