Skip to content

Instantly share code, notes, and snippets.

@mojaray2k
Created March 13, 2013 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mojaray2k/5154727 to your computer and use it in GitHub Desktop.
Save mojaray2k/5154727 to your computer and use it in GitHub Desktop.
Add a class when the text Value of two html elements are the same. This particular example is comparing the text of the Title Tag and and List Items in an Unordered list
//textcompare.js
$('ul.main-nav li').each(function () {
var title = $('title').text();
var mainlink = $(this).text();
if (title == mainlink) {
$(this).addClass('active');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment