I'm trying to addClass on prev() if $(this) is empty or removeClass if itsn't, but can't make it work:
function sfVide(){
var noentry = false;
$('.sf').each(function(){
if($(this).val().trim()==""){
noentry = true;
$(this).prev().addClass("test");
}
else {
$(this).prev().removeClass("test");
}
});
return noentry;
}
HTML
<a class="sf--trigger">Subs</a>
<div class="sf"></div>
Live codepen for testing: https://codepen.io/mSyx/pen/MWayKQx