I have dynamically created textboxes, and I want each of them to be able to display a calendar on click. The code I am using is:
$(".datepicker_recurring_start" ).datepicker();
Which will only work on the first textbox, even though all my textboxes have a class called datepicker_recurring_start.
Your help is much appreciated!
here is the trick:
DEMO
The
$('...selector..').on('..event..', '...another-selector...', ...callback...);syntax means:Add a listener to
...selector..(thebodyin our example) for the event..event..(‘focus’ in our example). For all the descendants of the matching nodes that matches the selector...another-selector...(.datepicker_recurring_startin our example) , apply the event handler...callback...(the inline function in our example)See http://api.jquery.com/on/ and especially the section about “delegated events”