Created
February 7, 2010 02:15
-
-
Save sgraber/297134 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
// Value swap (usually for search fields) | |
// whenever you have a search field and you want it to defaultly display a value “search…” | |
// and have that value empty out on focus, well this is how to do this with jQuery 1.4. | |
swap_val = []; | |
$(".swap").each(function(i){ | |
swap_val[i] = $(this).val(); | |
$(this).focusin(function(){ | |
if ($(this).val() == swap_val[i]) { | |
$(this).val(""); | |
} | |
}).focusout(function(){ | |
if ($.trim($(this).val()) == "") { | |
$(this).val(swap_val[i]); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment