Add days to JavaScript Date

HTML
<div class="container"> <div class="text-center"> <h1>Date difference</h1> <hr/> </div> <div class="row"> <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6"> <h3 class="text-center">Input data</h3> <form id="main-form"> <input type="number" placeholder="Type days amount" class="form-control" id="input-date" /> <br/> <button id="calc-button" type="button" class="btn btn-success">Calculate</button> </form> </div> <div class="col-xs-12 col-sm-6 col-md-6 col-lg-6"> <h3 class="text-center">Date difference date</h3> <span id="result"></span> </div> </div> </div>
CSS
JAVASCRIPT
Date.prototype.addDays = function(days) { var dat = new Date(this.valueOf()); dat.setDate(dat.getDate() + days); return dat; } var dat = new Date(); $("#main-form").on("submit", function(e){ e.preventDefault(); var days = parseInt($("#input-date").val()); $("#result").text(dat.addDays(days)); }); $("#calc-button").on("click", function(e){ e.preventDefault(); var days = parseInt($("#input-date").val()); $("#result").text(dat.addDays(days)); })
Expand for more options Login