Advertisement
timeshifter

Untitled

Feb 4th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function ($) {
  2.     $.fn.watermark = function (text) {
  3.         return this.each(function () {
  4.             $(this).attr('rel', text);
  5.             if($(this).val() == '') $(this).val(text).addClass('watermark');
  6.             $(this).focus(function () {
  7.                 if ($(this).val() == $(this).attr('rel')) {
  8.                     $(this).removeClass('watermark');
  9.                     $(this).val('');
  10.                 }
  11.             });
  12.             $(this).blur(function () {
  13.                 if ($(this).val() == '') {
  14.                     $(this).addClass('watermark');
  15.                     $(this).val($(this).attr('rel'));
  16.                 }
  17.             });
  18.         });
  19.     };
  20. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement