Stian Stian - 2 years ago 120
Javascript Question

Selecting last dynamically added textbox

I have a list of input boxes with dates (and the class name "newDate") in them and I can add more of them dynamically. When i try to get the value of the last added textbox, I always end up with first, which was a textbox rendered with the page.


Do I need to change my selector to catch the dynamically added textboxes or is there something else that I need to think of here? Is the location of the script with the selector relevant?

Answer Source

As long as the selector is run once the textboxes have been added, the following will work:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download