I am dynamically adding new elements and these elements looks like this:
<div id="cars">
<input type="text" name="car_added[]" class="car" />
<input type="text" name="car_added[]" class="car" />
<input type="text" name="car_added[]" class="car" />
<input type="text" name="car_added[]" class="car" />
<input type="text" name="car_added[]" class="car" />
</div>
If these elements would be static, I could add a handler on them easily with this code:
$(".car").each(function(){$(this).datetimepicker();})
and after clicking in the input, the date-time widget will display.
But how to do this for dynamically added elements? I've tried the following approach, but it doesn't work:
$('#cars').on('click', '.car', function() {
$(this).datetimepicker();
});
How to implement into this snippet the .each
part?
Thank you in advance.