-
-
Save ProxiBlue/e48236c890145eb29843245f3226e184 to your computer and use it in GitHub Desktop.
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
$('form input:text').each(function(index, elem) { | |
var eId = $(elem).attr('id'); | |
var label = null; | |
if (eId && (label = $(elem).parents('form').find('label[for='+eId.replace(':', '\\:')+']')).length === 1) { | |
$(elem).attr('placeholder', $(label).html().replace(/<\/?[^>]+(>|$)/g, "")); | |
$(label).addClass('hide-label'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adjust to only find text fields, and to escpae fields that contain ':' in field name (example Magento has billing:firstname)
Also strips any HTML from label (spans that designate * (required))