Why is it copying two lines when I only want one line to be cloned on button click?
Is there a way to make sure that only a single line is copied each time the button is clicked?
Here is my code:
$(function() {
$('.add-more-room-btn').click(function() {
let addMoreRoomClone = $(this).parents('.room-info').find('.row:first').html();
$(this).parents('.room-info').find('.row').append(addMoreRoomClone);
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="room-info">
<div class="row">
<div class="col-md-12">
<input type="text" placeholder="this need to copy" />
</div>
</div>
<button class="add-more-room-btn">Add More</button>
</div>