I have a function to manipulate class names -
function detectInputs() {
$(".myform").find("input.input-text").filter(function() {
if( $(this).val().length === 0 ) {
$(this).closest( "p.form-row" ).removeClass("parent-filled");
$(this).closest( "p.form-row" ).addClass("parent-empty");
} else {
$(this).closest( "p.form-row" ).removeClass("parent-empty");
$(this).closest( "p.form-row" ).addClass("parent-filled");
};
});
}
But it only works on elements that are already present when the page loads. More p.form-row
elements can be added dynamically. I know about .on()
but not sure where it would integrate with this function.