Created
March 13, 2013 18:19
-
-
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
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
//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