I've been trying to clone an element of a form and change the id of its children.
The thing I've not achieved is to clone the element for 3 or 4 times and the inputs of each clone need to have different id's, so I can work with the form.
It would be great if you could help me with some code, because I'm just beginning with JQUERY and Javascript!
Thanks a lot in advance!
HTML
<div class="input-form fcf-form-group">
<div class="form only">
<h3 class="fcf-h3">Room</h3>
<div class="form-section">
<div class="title-group">
<label for="zimmer" class="fcf-label">Room</label>
<select name="zimmer" id="zimmer" required>
<option value="double">Double</option>
<option value="single">Single</option>
</select>
</div>
</div>
</div>
<div class="form neighbour">
<div class="title-group small">
<label for="erwachsene" class="fcf-label">Adults</label>
<input type="number" id="erwachsene" name="erwachsene" min="1" max="5">
</div>
<div class="title-group small">
<label for="kinder" class="fcf-label">Children</label>
<input type="number" id="kinder" name="kinder" min="1" max="5">
</div>
<div class="title-group small">
<label for="alter" class="fcf-label">Age of the Child</label>
<select name="alter" id="alter" required>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
</div>
</div>
</div>
<div class="fcf-form-group">
<button class="clone-button">zimmer</button>
</div>
question from:
https://stackoverflow.com/questions/65927717/how-can-i-clone-a-form-and-change-the-id-of-its-inputs-for-2-3-times 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…