if ( !("placeholder" in document.createElement("input")) ) {
jQuery("input[placeholder], textarea[placeholder]").each(function() {
var val = jQuery(this).attr("placeholder");
if ( this.value == "" ) {
this.value = val;
}
jQuery(this).focus(function() {
if ( this.value == val ) {
this.value = "";
}
}).blur(function() {
if ( jQuery.trim(this.value) == "" ) {
this.value = val;
}
})
});
// Clear default placeholder values on form submit
jQuery('form').submit(function() {
jQuery(this).find("input[placeholder], textarea[placeholder]").each(function() {
if ( this.value == jQuery(this).attr("placeholder") ) {
this.value = "";
}
});
});
}
No comments:
Post a Comment