placeholder replacement


/ Published in: JavaScript
Save to your folder(s)

easy way to use placeholders before html5


Copy this code and paste it in your HTML
  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. });

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.