Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set placeholder default display in bootstrap-daterangepicker

HTML:

<input type="text" name="form" placeholder="Check In">

JS:

$('input[name="form"]').daterangepicker({
    singleDatePicker: true,
    showDropdowns: true,
});

I want to look like this.

example

bootstrap-daterangepicker official website:http://www.daterangepicker.com/

like image 637
sinchang Avatar asked Nov 17 '15 07:11

sinchang


2 Answers

UPDATE: You can do a work-around using this:

$('input[name="from"]').daterangepicker({
    singleDatePicker: true,
  showDropdowns: true,
});

   $('input[name="from"]').val('');
   $('input[name="from"]').attr("placeholder","Check In");
<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">
like image 94
Suchit kumar Avatar answered Nov 14 '22 22:11

Suchit kumar


For anyone reading this I believe that this is the correct answer:

$('input[name="from"]').val('');
$('input[name="from"]').attr("placeholder","Check In");

Source: https://stackoverflow.com/a/15252825

like image 42
Vasileios Litsas Avatar answered Nov 14 '22 21:11

Vasileios Litsas