Hi,
I'm generating fields dynamically using Jquery, and for each field I add at the end of the id a counter. I was wondering how I could do to remove the div that encompasses the button and the fields.
this is my form:
$contador = '';
foreach ($programas as $key => $formu){ $contador += 1;?>
<div id="campos_<?php echo $contador; ?>" name="campos[]" class="campos col-md-12" >
<input id="tbprogramacao_tv_hora_inicio_<?php echo $contador; ?>" class="form-control hora" type="text" value="<?php echo $formu->getHoraInicio(); ?>" name="tbprogramacao_tv[hora_inicio][]" maxlength="8">
<br><div class='btn btn-primary' style="border:solid 1px;" id="rmv" onclick="remover()"><span class="fa fa-minus"></span></div>
</div>
This is the function I'm creating to remove:
function remover()
{
$('.campos').remove();
}
but does not work. Anyone who has been through this can help me?