Created
March 18, 2011 11:09
-
-
Save hdragomir/875903 to your computer and use it in GitHub Desktop.
simple input hint plugin
This file contains hidden or 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
$.fn.hint = function(hint){ | |
var val = $(this).eq(0).bind('focus', function(){ | |
$(this).removeClass('hinting'); | |
if($(this).val() == hint) $(this).val(''); | |
}).bind('blur', function(){ | |
if($(this).val() == '') $(this).addClass('hinting').val(hint); | |
}).bind('change', function(){ | |
$(this).removeClass('hinting'); | |
}).val(); | |
if(! /\S/.test(val)) $(this).eq(0).val(hint).addClass('hinting'); | |
return this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment