Layui 總結(3)laydate 日期插件 添加選擇範圍

開發思路
   1.在要添加地方 給 test1 添加點擊事件  當 點擊的前提條件發生 再發生如下事情
   2. 在DOM元素 before 或者after 添加dom
   3. 添加dom之後 給dom設計點擊事件  模擬用戶點擊           

 

   $("#test1").click(function () {
      if (!$("#shangxun")[0]) {
        $(".laydate-btns-clear").before('<span class="laydate-btns-clear " id="shangxun" style="margin-right:20px">上旬</span>')
        $(".laydate-btns-clear:eq(0)").after('<span class="laydate-btns-clear " id="zhongxun" style="margin-right:20px">中旬</span>')
        $(".laydate-btns-clear:eq(1)").after('<span class="laydate-btns-clear " id="xiaxun" style="margin-right:200px">下旬</span>')
        
        $("#shangxun").click(function () {
          $(".layui-laydate-content td:not(.laydate-day-prev):eq(0)").click();
          $(".layui-laydate-content td:not(.laydate-day-prev):eq(9)").click();
        })
        $("#zhongxun").click(function () {
          $(".layui-laydate-content td:not(.laydate-day-prev):eq(10)").click();
          $(".layui-laydate-content td:not(.laydate-day-prev):eq(19)").click();
        })
        $("#xiaxun").click(function () {
          $(".layui-laydate-content td:not(.laydate-day-prev):eq(20)").click();
          $(".laydate-day-next:first").prev().click();
          console.log($(".laydate-day-next:first").prev())
        })
        
      }
    })

  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章