Skip to content

Instantly share code, notes, and snippets.

@KryptikOne
Last active December 31, 2015 20:49
Show Gist options
  • Select an option

  • Save KryptikOne/8043162 to your computer and use it in GitHub Desktop.

Select an option

Save KryptikOne/8043162 to your computer and use it in GitHub Desktop.
This tests whether the <body> has a certain class, and if it does, it finds a child within a parent and appends the placeholder attribute to the child.
(function($){
var someParentElement = $('#id_of_parent'),
someChildElement = $('#id_of_child'),
theBodyElement = $('body');
if(theBodyElement.hasClass('some_class_on_the_body_element')) {
someParentElement.find(someChildElement).append(function(){
$(this).attr('placeholder', 'Your Placeholder Text');
});
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment