2016-02-05 49 views

回答

4

您需要使用javascript中的.setDate()函數設置第二天的日期,一旦您從datepicker中使用getDate提取了所選日期。


這裏檢查我的工作小提琴:fiddle


使用Javascript/JQuery的:

$('.datepicker').datepicker().on('changeDate', function() { 
    var temp = $(this).datepicker('getDate'); 
    var d = new Date(temp); 
    $('#currentdate').html("The selected date is :" + d); 
    d.setDate(d.getDate() + 1); 
    $('#tomorrowdate').html("The next date is :" + d); 
}); 

HTML:

<div class="input-group date datepicker" data-provide="datepicker"> 
    <input type="text" class="form-control"> 
    <div class="input-group-addon"> 
    <span class="glyphicon glyphicon-th"></span> 
    </div> 
</div> 
<div id="currentdate"> 
</div> 
<div id="tomorrowdate"> 
</div> 
相關問題