user1865719 user1865719 - 2 months ago 21
CSS Question

Bootstrap datetimepicker for the id of div

I have the date picker working when I set the id for the input tag like the following:

<div class="col-sm-4" id="datepicker">
<input type="text" class="form-control" id="inputDate" placeholder="Date">
<span class="glyphicon glyphicon-calendar form-control-feedback" aria-hidden="true"></span>
</div>

<script type="text/javascript">
$(function () {
$('#inputDate').datetimepicker();
});
</script>


I just wonder why its not working if I used the div instead of the input tag ( the datepicker id), as I saw some examples online using the div instead of the input.

Answer

It wont work if you don't set class input-group on <div>

Check it here https://jsfiddle.net/a9729dc9/

Comments