Skip to content

Instantly share code, notes, and snippets.

@shodanuk
Created March 25, 2012 19:55
Show Gist options
  • Save shodanuk/2199360 to your computer and use it in GitHub Desktop.
Save shodanuk/2199360 to your computer and use it in GitHub Desktop.
Quick and dirty input placeholder shim using jQuery + Modernizr (Tested in IE7 + 8)
$('.lt-ie9 input[placeholder], .lt-ie9 textarea[placeholder]').each(function(){
var $this = $(this),
placeholder = $this.attr('placeholder');
$this.addClass('placeholder').val(placeholder);
$this.focus(function() {
$this.val('');
}).blur(function() {
if ($this.val() === '') {
$this.val(placeholder);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment