Created
September 18, 2009 01:06
-
-
Save 19WAS85/188814 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
// #1 | |
$(document).ready(function() { | |
// #2 | |
$('input[type=text]').each(function() { | |
// #3 | |
var input = $(this) | |
var label = input.attr('title') | |
var foreColor = '#AAA' | |
var backColor = '#000' | |
// #4 | |
if(label != null && input.val() == '') { | |
input.css('color', foreColor) | |
input.val(label) | |
} | |
// #5 | |
input.focus(function() { | |
if(input.val() == label) { | |
input.val('') | |
input.css('color', backColor) | |
} | |
}) | |
// #6 | |
input.blur(function() { | |
if(label != null && input.val() == '') { | |
input.css('color', foreColor) | |
input.val(label) | |
} | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment