Created
May 23, 2014 15:22
-
-
Save maxschulze/5854036a8feef618af78 to your computer and use it in GitHub Desktop.
placeholder example
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
$(document).ready -> | |
$("[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