Created
August 9, 2011 00:35
-
-
Save BlakeWilliams/1133146 to your computer and use it in GitHub Desktop.
Form Default Text in Coffeescript
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
jQuery ($) -> | |
jQuery.fn.defaultValue = (text) -> | |
this.each -> | |
return if this.value != "" or this.value == text | |
this.value = text | |
jQuery(this).toggleClass "inactive" | |
$(this).focus -> | |
if this.value == text or this.value == "" | |
this.value = "" | |
jQuery(this).toggleClass "inactive" | |
$(this).blur -> | |
if this.value == text or this.value == "" | |
this.value = text | |
jQuery(this).toggleClass "inactive" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment