1
The code below performs the insertion of a new select
by clicking the button, but this new list should be composed only with the remaining items, ie the new select
shall not possess the option
selected in select
previous.
$(document).ready(function(e) {
$('#addComp').on('click', function(){
$('.itemComposicao').append($('.itemComposicao').children(":first").html());
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="itemComposicao">
<div class="form-group">
<select class="composicao">
<option value="1">Alumínio</option>
<option value="2">Cobre</option>
<option value="3">PVC</option>
</select>
</div>
</div>
<button type="button" id="addComp">Inserir</button>
Update:
Note: after duplicating this item, how to make the option
"inserted" does not appear in selects
previous?
With
size()
the following error has been made:Uncaught TypeError: $(...).size is not a function
. However, when using thelength
worked perfectly.– lucasbento
Wellingthon, could you take a look at update?
– lucasbento
@luccasrodrigo I will give a check, so have to remove from the others also what was selected in the last certain ?
– NoobSaibot
Hello Wellingthon, we could continue this debate by chat?
– lucasbento