Return to Snippet

Revision: 62919
at July 23, 2013 14:21 by bitsculptor


Updated Code
$(document).ready(function() {
  if(!Modernizr.input.placeholder){
    $("input").each(function(){
      if($(this).val()=="" && $(this).attr("placeholder")!=""){
        $(this).val($(this).attr("placeholder"));
        $(this).focus(function(){
          if($(this).val()==$(this).attr("placeholder")) $(this).val("");
        });
        $(this).blur(function(){
          if($(this).val()=="") $(this).val($(this).attr("placeholder"));
        });
      }
    });
  }
});

Revision: 62918
at March 23, 2013 01:33 by bitsculptor


Initial Code
$(document).ready(function() {
  if(!Modernizr.input.placeholder){
    $("input").each(function(){
      if($(this).val()=="" && $(this).attr("placeholder")!=""){
        $(this).val($(this).attr("placeholder"));
        $(this).focus(function(){
          if($(this).val()==$(this).attr("placeholder")) $(this).val("");
        });
        $(this).blur(function(){
          if($(this).val()=="") $(this).val($(this).attr("placeholder"));
        });
      }
    });
  }
});

Initial URL
http://kamikazemusic.com/quick-tips/jquery-html5-placeholder-fix/

Initial Description
easy way to use placeholders before html5

Initial Title
placeholder replacement

Initial Tags
html5

Initial Language
JavaScript