Last active
July 11, 2017 15:11
-
-
Save ronnieduke/ff539714f61bdaf431fb to your computer and use it in GitHub Desktop.
jQuery Toggle Placeholder
This file contains hidden or 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
// Placeholder Toggle jQuery Extension | |
$.fn.togglePlaceholder = function() { | |
return this.each(function() { | |
$(this) | |
.data("holder", $(this).attr("placeholder")) | |
.focusin(function(){ | |
$(this).attr('placeholder',''); | |
}) | |
.focusout(function(){ | |
$(this).attr('placeholder',$(this).data('holder')); | |
}); | |
}); | |
}; | |
jQuery(document).ready(function($) { | |
// Toggle All Elements with Placeholder Attributes | |
$("[placeholder]").togglePlaceholder(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment