Forked from ramseyp/inf-soft-form-placeholder.js
Last active
August 29, 2015 14:07
-
-
Save willbraden/135250802c2aa6f78034 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CSS for this can be found here: https://gist.github.com/3827867 | |
jQuery(document).ready(function($){ | |
// Add classes to the labels of selects, text-inputs, email inputs and textareas | |
$('.infusion-form .infusion-field select').prev('label').addClass('label-select'); | |
$('.infusion-form .infusion-field input[type="email"], .infusion-form .infusion-field input[type="text"], .infusion-form .infusion-field textarea').prev('label').addClass('label-placeholder'); | |
$('.infusion-form .infusion-field input[type="email"], .infusion-form .infusion-field input[type="text"], .infusion-form .infusion-field textarea').focus(function(){ | |
$(this).prev('.infusion-field .label-placeholder').hide(); | |
}).blur(function(){ | |
if( $(this).val() == "" ){ | |
$(this).prev('.infusion-field .label-placeholder').show(); | |
} | |
}) | |
$('.infusion-form .infusion-field input[type="email"], .infusion-form .infusion-field input[type="text"], .infusion-form .infusion-field textarea').each(function(){ | |
if( $(this).val() != "" ){ | |
$(this).prev('.label-placeholder').hide(); | |
} | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment