The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Dynamically generated input is getting overriding by previous input

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #148234

    Hi :) so I have code here

    It’s suppose to generate 2 labels & 2 input fields, however only 1 is displayed. I know this is because of this line: $('.new_option').append(inputphone); I’m not dynamically generating a new ul & class here.

    How would you go about doing this?


    Using a for loop seems to solve the issue, though I’m not entirely sure why.

    Notice that I’m also applying unique classnames to each of the list items as well.


    Thanks! Trying this out in my project now, perhaps I should have started with a normal for loop in the first place. I guess each should be reserved for counting elements already on the DOM…

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.