On page reloads I have floating labels overlapping the input text if the form has been filled out before. To avoid this problem I want to alter the input text's style if there is data in the form.
Here is my code:
https://codepen.io/holly-williford/pen/pONYYM
document.getElementsByClassName("floating").addEventListener("load", hideLabel);
function hideLabel() {
if(!$('input').val() ) {
$('floating').addClass('warning');
} else {
}
}
<label class="floating">Test</label>
<input></input>
warning {
color: red;
}