Created
February 29, 2012 20:52
-
-
Save ejholmes/1944274 to your computer and use it in GitHub Desktop.
Snippet of javascript for pseudo HTML5 placeholder.
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
$(function() { | |
$('.placeholder input[type=text]').each(function() { | |
var placeholder = $(this).val(); | |
$(this).focus(function() { | |
if ($(this).val() == placeholder) { | |
$(this).val(''); | |
} | |
}); | |
$(this).blur(function() { | |
if ($(this).val() == '') { | |
$(this).val(placeholder); | |
} | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment