Created
December 27, 2015 05:53
-
-
Save weskerfoot/c6c4c9d887cab4a9ef8c 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
function genfocin(object, original) { | |
return function() { | |
var text = $(object).val(); | |
if (text == original) { | |
$(object).val(""); | |
} | |
}; | |
} | |
function genfocout(object, original) { | |
return function() { | |
if ($(object).val() === "") { | |
$(object).val(original); | |
} | |
}; | |
} | |
$("input").focusin( | |
function() { | |
var text = $(this).val(); | |
var f = genfocin(this, text); | |
$(this).focusout(genfocout(this, text)); | |
$(this).off("focusin"); | |
$(this).focusin(f); | |
f(); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment