Reputation: 2232
I have a dynamic form that may have repeated datepickers elements. I am using bootstrap datepicker.
<div class="col-xs-11">
<div class="input-group date" id="datepicker">
<input type="text" class="form-control be-form-control form-input" aria-describedby="basic-addon2" />
<span class="input-group-addon calendar-icon" id="basic-addon2">
<i class="glyphicon glyphicon-calendar" aria-hidden="true"></i>
</span>
</div>
</div>
This element can be repeated . My issue is that with bootstrap datepicker I have included script as,
$('#datepicker').datepicker();
But if I have two such datepicker fields then one works and other does not because both now have same id . How can dynamic no of datepickers with unique ids can be added.
Upvotes: 0
Views: 187
Reputation: 722
if you have several datePicker then you should use a class instead of an id (an id must be unique)
$('.classDatePicker').datepicker();
Upvotes: 1