Skip to content

Instantly share code, notes, and snippets.

@ryanburgess
Created February 11, 2014 01:58
Show Gist options
  • Save ryanburgess/8927964 to your computer and use it in GitHub Desktop.
Save ryanburgess/8927964 to your computer and use it in GitHub Desktop.
Placeholder text in old browsers (pear.rs)
$(function(){
var d = "placeholder" in document.createElement("input");
if (!d){
$("input[placeholder]").each(function(){
$(this).val(element.attr("placeholder")).addClass('placeholder');
}).bind('focus',function(){
if ($(this).val() == element.attr('placeholder')){
$(this).val('').removeClass('placeholder');
}
}).bind('blur',function(){
if ($(this).val() == ''){
$(this).val(element.attr("placeholder")).addClass('placeholder');
}
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment