Created
October 3, 2012 16:03
-
-
Save ramseyp/3827830 to your computer and use it in GitHub Desktop.
Javascript used to make Infusionsoft form labels act as placeholders
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