Skip to content

Instantly share code, notes, and snippets.

@19WAS85
Created September 18, 2009 01:06
Show Gist options
  • Save 19WAS85/188814 to your computer and use it in GitHub Desktop.
Save 19WAS85/188814 to your computer and use it in GitHub Desktop.
// #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