Created
August 13, 2013 21:45
-
-
Save jonesch/6226018 to your computer and use it in GitHub Desktop.
Simple Placeholder Fallback that is dependent on Modernizer. I am sure there is a cleaner way, but I just wanted to see if I could do it from scratch.
This file contains 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
if(!Modernizr.input.placeholder) { | |
$('[placeholder]').each(function(i){ $(this).val($(this).prop('placeholder')); }); | |
$('[placeholder]').on({ | |
'focus' : function(evt){ | |
if($(this).val() === $(this).prop('placeholder')) { $(this).val(''); } | |
}, | |
'blur' : function(evt){ | |
if($(this).val() !== $(this).prop('placeholder')) { $(this).val($(this).prop('placeholder')); } | |
} | |
}); | |
$('.block-internal-form').submit(function(){ | |
$('[placeholder]').each(function(i){ | |
if($(this).val() === $(this).prop('placeholder')) { $(this).val(''); } | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment