Skip to content

Instantly share code, notes, and snippets.

@arildm
Forked from kylerush/label-to-placeholder.js
Last active August 29, 2015 14:06
Show Gist options
  • Save arildm/384d65ae75ffe625631c to your computer and use it in GitHub Desktop.
Save arildm/384d65ae75ffe625631c to your computer and use it in GitHub Desktop.
$('form :input').each(function(index, elem) {
var eId = $(elem).attr('id');
var label = null;
if (eId && (label = $(elem).parents('form').find('label[for='+eId+']')).length === 1) {
$(elem).attr('placeholder', $(label).html());
$(label).addClass('hide');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment