Created
December 9, 2011 05:25
-
-
Save AndorChen/1450312 to your computer and use it in GitHub Desktop.
jQuery HTML5 Placeholder fix
This file contains hidden or 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
/** | |
* 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