Follow the HTML:
<div class="tab-pane" id="etapa3">
<div class="well">
<div class="row informativo">
<!-- Aqui vai ser inserida a tabela via Jquery -->
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<label class="control-label">Capital de Giro:</label>
<div class="input-group">
<span class="input-group-addon">R$</span>
<input type="text" class="form-control money" name="txt_capitalGiro">
</div>
</div>
<div class="row">
<div class="form-group col-xs-12 col-sm-2 col-md-2 col-lg-2 ">
<button type="button" data-aprovacao="Aprovado" class="btn btn-primary btn-block aprovado">Aprovado</button>
</div>
<div class="form-group col-xs-12 col-sm-2 col-md-2 col-lg-2 ">
<button type="button" data-aprovacao="Reprovado" class="btn btn-primary btn-block reprovado">Reprovado</button>
</div>
<div class="form-group col-xs-12 col-sm-2 col-md-2 col-lg-2 ">
<button type="button" data-aprovacao="Revisar" class="btn btn-primary btn-block revisar">Revisar</button>
</div>
<input name="reg_etapa3" type="hidden">
</div>
<div class="row div-Invisivel">
<div class="panel panel-danger">
<div class="panel-heading">Justificativa:</div>
<div class="panel-body">
<textarea class="form-control" name="just_3" rows="5"></textarea>
</div>
</div>
</div>
<div class="panel panel-info">
<div class="panel-heading">Observações:</div>
<div class="panel-body">
<textarea class="form-control" name="txtArea_observacaoEtapa3" rows="5"></textarea>
</div>
</div>
<div class="row">
<div class="form-group col-xs-12 col-sm-12 col-md-7 col-lg-7">
<label class="control-label">Responsável:</label>
<input type="text" class="form-control" id="colab_3" name="colab_3">
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-2 col-lg-3">
<label class="control-label">Data:</label>
<input type="text" class="form-control" id="data_3" name="data_3">
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-2 col-lg-2">
<label class="control-label">Hora:</label>
<input type="text" class="form-control" id="hora_3" name="hora_3">
</div>
</div>
</div> <!-- Fecha Etapa 03 -->
I'd like to get all label texts within .form-group
.
Here is the code:
$("#etapa3").find(".form-group").not('.well .form-group').each(function(){
console.log($(this).find("label").text());
});
However, the script tries to get text from a label on the buttons and console.log returns blank space. Follow photo:
I do not know why this happens. Would anyone explain?