Guest User

Untitled

a guest
Jun 25th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. /*
  2. * This function checks to see if the loaded browser includes "placeholder" support.
  3. * If the browser doesn't include "placeholder" support, then it will emulate it using
  4. * jQuery. Tested in IE6-9, Firefox 3.6-4, Chrome 6-7, Opera 10.6
  5. *
  6. * HTML: <input type="text" placeholder="Text">
  7. *
  8. * Requires: jQuery 1.4.x
  9. *
  10. */
  11. if(!(function(){ return 'placeholder' in $('<input>').get(0); })())
  12. {
  13. $("input[placeholder],textarea[placeholder]").each(function()
  14. {
  15. $(this).val($(this).attr("placeholder"));
  16. $(this).bind('focus.placeholder',function()
  17. {
  18. if($(this).val()==$(this).attr("placeholder")) $(this).val("");
  19. }).bind('blur.placeholder',function(){
  20. if($(this).val()=="") $(this).val($(this).attr("placeholder"));
  21. });
  22. });
  23. }
Add Comment
Please, Sign In to add comment