Hello, I have a database of academic information; I need this field to be duplicated and removed, but when I remove only the first DIV and deleted; I use the javascrip below, when the person clones the field appears the 'X' to delete, but if it duplicates more than once the last 'X' will delete the first field, no matter what 'X' always removes the first field.
HTML:
<div id="academico" class="tab-pane fade">
<div id="academico1">
<div class="col-xs-9">
<label for="ex3">Formação</label>
<input class="form-control input-sm" title="Digite o nome do curso" id="FormacaoAcademica" name="estudo[]" type="text" >
</div>
<div class="col-xs-3">
<label for="ex3">Status</label>
<select class="form-control input-sm" id="FormacaoAcademica" name="estudo[]" >
<option selected disabled>Selecione</option>
<option>Cursando</option>
<option>Concluido</option>
</select>
</div>
<div class="col-xs-9">
<label for="ex3">Nível</label>
<input class="form-control input-sm" title="Especifique se o curso trata-se de curso tecnico, graduação ou pos-graduação" name="estudo[]" type="text" id="FormacaoAcademica">
</div>
<div class="col-xs-3">
<label for="ex3">Ano de conclusão</label>
<input class="form-control input-sm" title="Digite o Ano de Conclusão" name="estudo[]" type="text" id="FormacaoAcademica">
</div>
<div class="col-xs-3" id="botoesacademico">
<a class="hidden" href="javascript:void(0)" id="btnova_tarefa" onclick="Removeacademico()" title="Remover"><img src="imagens/rem.png"/></a>
</div>
<hr style="clear:both;">
</div>
<center><a class="inline" href="javascript:void(0)" id="btnova_tarefa" onclick="Clonaacademico()" title="Adicionar"><img src="imagens/add.png"/></a></center>
</div>
javascrip to Clone:
function Clonaacademico() { $("#academico1").clone().fadeIn(700).insertBefore($("#academico1")).find('#FormacaoAcademica').val('');
document.getElementById("btnova_tarefa").setAttribute("class", "inline");
count = count + 1;}
Javascrip to exclude:
function Removeacademico() {
$('#academico div#academico1:this').fadeOut(700, function () {
$('#academico div#academico1:this').remove();
});}