Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * This function checks to see if the loaded browser includes "placeholder" support.
- * If the browser doesn't include "placeholder" support, then it will emulate it using
- * jQuery. Tested in IE6-9, Firefox 3.6-4, Chrome 6-7, Opera 10.6
- *
- * HTML: <input type="text" placeholder="Text">
- *
- * Requires: jQuery 1.4.x
- *
- */
- if(!(function(){ return 'placeholder' in $('<input>').get(0); })())
- {
- $("input[placeholder],textarea[placeholder]").each(function()
- {
- $(this).val($(this).attr("placeholder"));
- $(this).bind('focus.placeholder',function()
- {
- if($(this).val()==$(this).attr("placeholder")) $(this).val("");
- }).bind('blur.placeholder',function(){
- if($(this).val()=="") $(this).val($(this).attr("placeholder"));
- });
- });
- }
Add Comment
Please, Sign In to add comment