Last active
April 8, 2016 15:55
-
-
Save clayb/81f00053eb658176123e to your computer and use it in GitHub Desktop.
placeholder js script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (!Modernizr.input.placeholder) { | |
$('[placeholder]').focus(function() { | |
var input; | |
input = $(this); | |
if (input.val() === input.attr('placeholder')) { | |
input.val(''); | |
return input.removeClass('placeholder'); | |
} | |
}).blur(function() { | |
var input; | |
input = $(this); | |
if (input.val() === '' || input.val() === input.attr('placeholder')) { | |
input.addClass('placeholder'); | |
return input.val(input.attr('placeholder')); | |
} | |
}).blur().parents('form').submit(function() { | |
return $(this).find('[placeholder]').each(function() { | |
var input; | |
input = $(this); | |
if (input.val() === input.attr('placeholder')) { | |
return input.val(''); | |
} | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment