Passing an array value into the jQuery selector method? -
at moment in js statically define input id's want associate datepicker script with.
like so:
$('datepicker1').gldatepicker();
however create dynamic have refactored loop multiple fields need datepicker can phone call them in loop.
datearray[y] = "datepicker" + i; //out of loop scope (i = 0; < datearray.length; i++) { $(datearray[i]).gldatepicker(); }
it not seem work , have checked there values in array printing values log.
is limitation of jquery?
thanks
you need set id "#"
$("#" + datearray[i]).gldatepicker();
jquery jquery-selectors
No comments:
Post a Comment