JSFiddle - React, Tailwind, and code Playground
HTML
<input type="date" id="startDate" />
<input type="date" id="endDate" />
JavaScript
$("#endDate").click(function () {
var date1 = new Date($("#startDate").val());
var date2 = new Date($("#endDate").val());
console.log(date2);
var timeDiff = Math.abs(date2.getTime() - date1.getTime());
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
alert(diffDays);
});