How to target dynamic created form elements
Hi,
Really new to jQuery but getting the hang of it. I have a form that has a table that adds rows dynamically, 4 columns with each having a form element. i end up with the following when the page loads, created dynamically:
- <tr>
- <td><input type="text" name="datepicker0" id="datepicker"></td>
- <td><input type="text" name="date_to0" id="datepicker" size="20"></td>
- <td><input type="text" name="employer0" id="employer0" size="20"></td>
- <td><input type="text" name="position0" id="position0" size="20"></td>
- <td><input type="button" value="Delete"></td>
- </tr>
for the first cell, I am adding a text box, applying the "datepicker" id as follows
- var cell1 = row.insertCell(0);
- var el1 = document.createElement('input');
- el1.type = 'text';
- el1.name = 'datepicker' + iteration;
- el1.id = 'datepicker';
- cell1.appendChild(el1);
pretty staightforward and it works great.
however, when i try to apply the standard jQuery datepicker to the element in the dynamically created table, im not getting any action after the page loads --
- $(function() {
- $("#datepicker").datepicker();
- $.datepicker.setDefaults($.datepicker.regional['']);
- });
Any help would be great --
thanks!