this might be a basic question about jquery, but I hope someone will clarify for me anyway.
I have created two datepickers on my page (pseudo-code):
<input id="datepicker1" class="datepicker"/>
<input id="datepicker2" class="datepicker" />
jQuery(".datepicker").datepicker();
if I do jQuery(“#datepicker1”) will I then get the same datepicker-instance which was created using the class-selector?
(I have tried the above because I need to add “onSelect” to datepicker1, but it does not work.)
thanks
Thomas
Sure thing (as @BoltClock points out, you will retrieve the same DOM element that the datepicker was applied to). Here’s how you could define an event handler for just one of those datepicker inputs:
The event handler will only be fired for
#datepicker1.Example: http://jsfiddle.net/andrewwhitaker/TsHwa/
Here’s an alternate way of only executing code in
onSelectfor theinputwith iddatepicker1:Example: http://jsfiddle.net/andrewwhitaker/rdxy6/