Created
October 2, 2012 18:30
-
-
Save mdb/3822096 to your computer and use it in GitHub Desktop.
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
var placeholderElems = $('[data-test]'); | |
var placeholderAttr = 'data-test'; | |
var placeholderClass = 'placeholder'; | |
placeholderElems.focus(function() { | |
var input = $(this); | |
if (input.val() === input.attr(placeholderAttr)) { | |
input.val(''); | |
input.removeClass(placeholderClass); | |
} | |
}).blur(function() { | |
var input = $(this); | |
if (input.val() === '' || input.val() === input.attr(placeholderAttr)) { | |
input.addClass(placeholderClass); | |
input.val(input.attr(placeholderAttr)); | |
} | |
}).blur(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment