Created
April 8, 2013 21:00
-
-
Save quantizor/5340444 to your computer and use it in GitHub Desktop.
Make placeholders disappear on focus, instead of when you start typing. (jQuery)
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
;(function($){ | |
$(document).ready(function(){ | |
var x = $('[placeholder]'); | |
for( var i=0, len=x.length; i<len; i++ ){ | |
x.eq(i).attr('data-placeholder', x.eq(i).attr('placeholder')); | |
} | |
x.on('focus', function(){ $(this).attr('placeholder', ''); }) | |
x.on('blur', function(){ $(this).attr('placeholder', $(this).data('placeholder')); }); | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment