Created
April 8, 2013 11:24
-
-
Save MaciekBaron/5336075 to your computer and use it in GitHub Desktop.
A simple fallback for HTML5 placeholders (using jQuery)
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
if (!("placeholder" in document.createElement("input"))) { | |
$("[placeholder]").each(function () { | |
var placeholder = $(this).attr("placeholder"); | |
$(this).val(placeholder).focus(function () { | |
if ($(this).val() === placeholder) { | |
$(this).val(""); | |
} | |
}).blur(function () { | |
if ($(this).val().length === 0) { | |
$(this).val(placeholder); | |
} | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment