Posted By

bitsculptor on 03/23/13


Tagged

placeholder html5


Versions (?)

placeholder replacement


 / Published in: JavaScript
 

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

easy way to use placeholders before html5

  1. $(document).ready(function() {
  2. if(!Modernizr.input.placeholder){
  3. $("input").each(function(){
  4. if($(this).val()=="" && $(this).attr("placeholder")!=""){
  5. $(this).val($(this).attr("placeholder"));
  6. $(this).focus(function(){
  7. if($(this).val()==$(this).attr("placeholder")) $(this).val("");
  8. });
  9. $(this).blur(function(){
  10. if($(this).val()=="") $(this).val($(this).attr("placeholder"));
  11. });
  12. }
  13. });
  14. }
  15. });

Report this snippet  

You need to login to post a comment.