First of all to introduce JS files and CSS files
<script src= "Jquery-1.11.2.min.js" ></script><script src= "Bootstrap.min.js" ></script>< Script src= "moment.js" ></script><script src= "daterangepicker.js" ></script><link href= " Bootstrap.min.css "rel=" stylesheet "type=" Text/css "/><link href=" Daterangepicker-bs3.css "rel=" stylesheet " Type= "Text/css"/><link href= "Http://www.jq22.com/jquery/font-awesome.4.6.0.css" rel= "stylesheet" >
Here is the div section:
<div class= "col-xs-12" ><!--Date Query component--<label class= "col-sm-1 Control-label TJ" > Release date: </ label> <div class= "Col-xs-4 TJ" > <form class= "form-horizontal" > <fieldset> <div class= "Control-group" > <div class= "Controls" > <div class= "Input-prepend input-group" > <span class= "Add-on Input-group-addon" > <i class= "Glyphicon glyphicon-calendar fa Fa-calendar" ></i></span> <input type= "text" readonly style= "width:200px" name= "Reservation" id= "Reservation" class= "Form-control" value= "Please select query Date"/> </div> </div> </div> </fieldset> </form> </div></div>
Finally, the JS section:
<script type= "Text/javascript" >//Date Query JS component $ (document). Ready (function () {$ (' #reservation ') ). Daterangepicker (null, function (start, end, label) {Console.log (start.toisostring (), end.toisostring (), L Abel); }); }); var rqstart = ""; var rqend = ""; DateTime method $ (document). Ready (function () {$ (' input[name= ' reservation "] '). Daterangepicker ({ /*format: ' Yyyy-mm-dd ', StartDate: ' 2013-01-01 ', endDate: ' 201 3-12-31 ' * *}, function (Start, end, label) {//alert (' A date range was Cho Sen: ' + start.format (' yyyy-mm-dd ') + ' to ' + end.format (' yyyy-mm-dd ')); Start = Start.format (' yyyy-mm-dd ');//.format () converts any data into a string end = End.format (' yyyy-mm-dd '); /* Start at the end of add */Rqstart = start; Rqend = End; } ); }); </script>
The effect is as shown
JavaScript implementation time Query