JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="container">
<div class="col-sm-12">
<div class="bloco_01">
<!-- Secretaria -->
<div class="form-group">
<div class="col-sm-11 inputGroupContainer">
<label class="col-sm-2 control-label">Secretaria</label>
<div class="col-sm-9">
<select class="form-control" id="cd_secretaria[]" name="cd_secretaria[]">
<option value="0">--Selecione a Secretaria--</option>
<option value="1">Administracao</option>
<option value="2">Assuntos Juridicos</option>
<option value="3">Chefia de Gabinete do Prefeito</option>
<option value="4">Cidadania, Assistencia e Inclusao Social</option>
<option value="5">Comunicacao</option>
<option value="6">Cooperacao Internacional</option>
</select>
</div>
<div class="col-sm-1">
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-11 inputGroupContainer">
<label for="nu_qtd_vagas_por_secretaria[]" class="col-sm-2 control-label">Qtde Vagas por...
JavaScript
$(document).ready(function () {
var bloco = $('[class^="bloco_"]');
var current_id = parseInt(bloco.attr("class").split("_")[1], 10);
$(document).bind('keypress', 'input', function (e) {
// if the letter is not digit then display error and don't type anything
if (e.which !== 8 && e.which !== 0 && (e.which < 48 || e.which > 57)) {
//display error message
$('.errmsg').css('color', 'red');
$('.errmsg').html('Digits Only').show().fadeOut('slow');
return false;
}
}).unbind('keypress').bind('keypress', function (e) {
// if the letter is not digit then display error and don't type anything
if (e.which !== 8 && e.which !== 0 && (e.which < 48 || e.which > 57)) {
//display error message
$('.errmsg').css('color', 'red');
$('.errmsg').html('Digits Only').show().fadeOut('slow');
return false;
}
});
$(document).on('click', '.btn-add', function (e) {
e.preventDefault();
var div_elements = $('form:first .elements'); // SELECIONA DIV ELEMENTS
var div_bloco = div_elements.find('.bloco_01:first'); // SELECIONA 1o BLOCO
var last_class_number = parseInt(div_elements.find('div[class^=bloco_]:last').attr("class").split("_")[1], 10); // PEGA NUM DO ULTIMO BLOCO
nextElement(div_bloco, last_class_number);
div_elements.find('div[class^=bloco_]:last span')
.removeClass('glyphicon-plus')
.addClass('glyphicon-minus')
.parent('button.btn-add')
.removeClass('btn-add')
.addClass('btn-del');
$('div[class^=bloco_]:last input').val('');
...