I need to add css to a sibling select element of a span element only if the span element has content.
The html is this:
<td class="ruleField">
<select name="rules[field][]" class="form-select " >
<option value="0">-- Select --</option>
<option value="554">Identifier</option>
<option value="548">Display Name</option>
</select>
<span class="rules-error">Not allowed.</span>
</td>
This works:
if( $('.rules-error').text().length>0){
$('.rules-error').siblings().css('background-color','green')
}
but i need it to be specific to that spans sibling select.
But this does not work:
if( $('.rules-error').text().length>0){
$(this).siblings().css('background-color','green')
}