Use jQuery to match variable text?

Posted by VUELA on Stack Overflow See other posts from Stack Overflow or by VUELA
Published on 2010-04-09T19:30:09Z Indexed on 2010/04/09 19:33 UTC
Read the original article Hit count: 139

Filed under:
|

Hello! I have a sidebar navigation that lists blog entry titles down the side of the page. I am trying to write some jquery that will check the text in the title of the current full blog entry page and match it with the corresponding title in the sidebar navigation so that I can apply a class to style for an active state link ... but I'm not quite getting it! Here is the link to an example page: http://ncw-commercial.com/property-listings/eastpoint-plaza-lot.html, and below is my current code. I have also tried using :contains but could not figure out how to get that to work with a variable rather than direct text.

$('.single-journal-entry-wrapper .journal-entry .title').each(function(){ 
      var activeTitle = $(this).text();
      $(".feedburnerFeedBlock .headline a").filter(function(index) {
         return $(this).text() == "activeTitle";
      }).parent().addClass("activeTitle");
}); 

© Stack Overflow or respective owner

Related posts about squarespace

Related posts about jQuery