jQuery Plugin not working for elements added dynamically
How do I get a jQuery Plugin working for elements added dynamically? I'm trying to add few date pickers to the DIV
datesList
each time you cick the Add button. The plugin doesnt work for the textboxes that are added dynamically. Can some one please advice?
Thank You
HTML
- <div class="datesList">
- <div class="date">
- <input type="text" class="date-picker"/>
- </div>
- </div>
- <div class="addDate">
- Add Date
- </div>
JS
- $(".date-picker").datepicker();
- $(".addDate").click(function(){
- var dList = $(".datesList");
- dList.find(".date").first().clone(false).appendTo(dList);
- });