skill-assessment-app/app/assets/javascripts/form-animation.js

17 lines
665 B
JavaScript
Raw Normal View History

// Text Input Label Animation
var textInput = $('[type="color"], [type="date"], [type="datetime"], [type="datetime-local"], [type="email"], [type="month"], [type="number"], [type="password"], [type="search"], [type="tel"], [type="text"], [type="time"], [type="url"], [type="week"], input:not([type]), textarea');
textInput.prev('label').addClass('loaded');
$(textInput).each(function() {
if( $(this).val() ) {
$(this).prev('label').addClass('animate');
}
});
$(textInput).on('focus', function() {
$(this).prev('label').addClass('animate');
}).on('focusout', function() {
if( !$(this).val() ) {
$(this).prev('label').removeClass('animate');
}
});