Skip to content
Advertisement

Duplicate inputs when append using jQuery

Here is the code:

JavaScript

Here starts the problem with the following script according to the tour selection I’m trying to set up a minimum and maximum so that the user can’t choose more numbers for the people on the tour.

The problem is that when the user select first one option, and then realised that the best option is another one, when he/she does another selection the input created with jQuery that was appended remains and because of the new selection a new input is created.

The intention is that if the user chooses option 1 the input append appears according to option one, but if the user regrets and prefers option 2 that the input for the option 1 disappears and a new input according to option 2 appears and so on for the entire if conditions.

JavaScript

Advertisement

Answer

Move your script out from inside the div with id pax, then Clear your html of the element with id pax before appending:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement