Skip to content

Instantly share code, notes, and snippets.

@jakebresnehan
Created March 30, 2012 03:22
Show Gist options
  • Save jakebresnehan/2246189 to your computer and use it in GitHub Desktop.
Save jakebresnehan/2246189 to your computer and use it in GitHub Desktop.
Finds text and wrap with element
//Finds the text 'pancakes' in .food and wraps it with a span which has the sauce class. YUMMY!
$('.food:contains(pancakes)').each(function(){
$(this).html(
$(this).html().replace('pancakes','<span class=\'sauce\'>pancakes</span>')
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment