Created
August 14, 2013 18:16
-
-
Save ewillhite/6233854 to your computer and use it in GitHub Desktop.
Placeholder fallback
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
# ------ HTML5 Placeholder fallback --------- | |
unless Modernizr.input.placeholder | |
$("[placeholder]").focus(-> | |
input = $(this) | |
if input.val() is input.attr("placeholder") | |
input.val "" | |
input.removeClass "placeholder" | |
).blur(-> | |
input = $(this) | |
if input.val() is "" or input.val() is input.attr("placeholder") | |
input.addClass "placeholder" | |
input.val input.attr("placeholder") | |
).blur() | |
$("[placeholder]").parents("form").submit -> | |
$(this).find("[placeholder]").each -> | |
input = $(this) | |
input.val "" if input.val() is input.attr("placeholder") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment