I have a problem finding an Element inside Another and checking if it is the first element, see the structure:
<div class="form-group">
<input type="text" id="teste1" placeholder="Texto">
<label for="teste1">Texto</label>
<p class="help-block">Teste.</p>
</div>
<div class="form-group">
<label>Texto</label>
<p>Texto</p>
<p class="help-block">Teste.</p>
</div>
I want to select the tag label
within form-group
but only if it is the first element, I tried this way in jQuery
:
if ( $('.form-group').children().first().is('label') ) {
$(this).parent().css("padding-top", "0");
}
But the answer is false
.