HTML:
<input type="text" name="form" placeholder="Check In">
JS:
$('input[name="form"]').daterangepicker({
singleDatePicker: true,
showDropdowns: true,
});
我希望看起来像这样。
bootstrap-daterangepicker官方网站:http://www.daterangepicker.com/
答案 0 :(得分:1)
更新:您可以使用此方法进行解决:
$('input[name="from"]').daterangepicker({
singleDatePicker: true,
showDropdowns: true,
});
$('input[name="from"]').val('Check In');
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js" type="text/javascript"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.css" />
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css">
<input type="text" name="from" placeholder="Check In" class="form-control">
&#13;
答案 1 :(得分:0)
只需添加 autoUpdateInput: false
。
$('input[name="form"]').daterangepicker({
singleDatePicker: true,
showDropdowns: true,
autoUpdateInput: false,
});