<HTML>
 
<body>
 
<script>
 
    //dateObj是一个日期对象,days表示给这个日期加多少天,比如说4,5(天)  
 
    function dateAdd(dateObj,days){  
 
          var tempDate = dateObj.valueOf();  
 
          tempDate = tempDate + days * 24 * 60 * 60 * 1000;  
 
         tempDate = new Date(tempDate);  
 
          return tempDate;  
 
     }  
 
      function changeDays(datevalues, days) {
 
    //然后使用,创建一个日期对象  
 
   var dateValue = datevalues.split("-");  
 
   var custArvDateTwoValue = new Date(dateValue[0],dateValue[1]-1,dateValue[2]);  
 
   //调用dateAdd,加两天  
 
   custArvDateTwoValue = dateAdd(custArvDateTwoValue,days);  
 
   var year = custArvDateTwoValue.getFullYear();  
 
   var month = custArvDateTwoValue.getMonth() + 1;  
 
   var days = custArvDateTwoValue.getDate();  
 
  month = month <= 9 ? "0"+month : month;  
 
   days = days <= 9 ? "0"+days : days;  
 
   document.getElementById("XX").value = year + "-" + month + "-" +days;  
 
   }
 
</script>
 
增加指定的天数
 
<input type="text" id="yy" value="" οnclick="changeDays(this.value, 3)"/>
 
<input type="text" id="XX" value=""/>
 
</body>
 
<html>