Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
jQuery HTML5 Placeholder fix
/**
* jQuery.HTML5 placeholder - Placeholder plugin for input fields
* Written by Ludo Helder (ludo DOT helder AT gmail DOT com)
* Licensed under the WTFPL (http://sam.zoy.org/wtfpl/).
* Date: 2010/11/18
*
* @author Ludo Helder
* @version 1.0.1
*
**/
$(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