2017-03-08 142 views
1

我想克隆一個datepicker一個星期前,當我得到它或克隆功能不起作用,或datepicker函數,我希望他們能幫助我!謝謝克隆日期選擇器

從博客中刪除代碼

<script type="text/javascript"> 
    $(document).ready(function() { 
     $('#btnAdd').click(function() { 
      var num  = $('.clonedInput').length; 
      var newNum = new Number(num + 1); 

      var newElem = $('#input' + num).clone().attr('id', 'input' + newNum); 

      newElem.children(':first').attr('id', 'name' + newNum).attr('name', 'name' + newNum); 
      $('#input' + num).after(newElem); 
      $('#btnDel').attr('disabled',''); 

     if (newNum == 5) 
      $('#btnAdd').attr('disabled','disabled'); 
    }); 

    $('#btnDel').click(function() { 
     var num = $('.clonedInput').length; 

     $('#input' + num).remove(); 
     $('#btnAdd').attr('disabled',''); 

     if (num-1 == 1) 
      $('#btnDel').attr('disabled','disabled'); 
    }); 

    $('#btnDel').attr('disabled','disabled'); 
}); 
</script> 


PróximosPasos

 <input type="button" id="btnDel" value="x" class="btn btn-default"/> 
     <input type="button" id="btnAdd" value="+" class="btn btn-primary"/> 
    </div> 

 <div class="col-md-4"> 
    <input type="text" class="form-control" id="proximospasos1" name="proximospasos1" required value="" placeholder="Próximos Pasos"> 
    </div> 



    <div class="col-md-4"> 

    <input type="text" class="form-control" id="participantes1" name="participantes1" required value="" placeholder="Participantes"> 
     </div> 

    <div class="col-md-2"> 

      <div class="input-group date"> 
      <input type="text" class="form-control date" id="fecha2" name="fecha2"/> 
     <span class="input-group-addon"> 
      <i class="fa fa-calendar" aria-hidden="true"></i></span> 
      </div> 
      </div> 
      </span> 

</div> 

回答

0

試試這個

改變這一行:

var newElem = $('#input' + num).clone().attr('id', 'input' + newNum); 

要這樣:

var newElem = $('#input' + num).clone().datepicker().attr('id', 'input' + newNum); 
相關問題