/ Published in: JavaScript
easy way to use placeholders before html5
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$(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")); }); } }); } });
URL: http://kamikazemusic.com/quick-tips/jquery-html5-placeholder-fix/