I believe the answer lies in jQuery, and I've tried several solutions on this.
The root of my problem is that I am modifying this website and I'm not the one who designed it. It's made in wordpress, but the theme is heavily customized. It's a one page site with several sections, and a menu at the top with anchor links for those sections. I've been able to change the highlight class on click, but I need it to also change when the corresponding section is visible on screen. I know this should be simple, but the mere complicatedness of this site is throwing me off.
Here is the HTML for the menu: (some of these classes point to a large part of the style.css file. I'm not sure if it's worth mentioning, so let me know)
<div class="ddsmoothmenu"><ul id="menu-home-2" class="menu">
<li class="menu-item"><a class="link" href="#home">Home</a></li>
<li class="menu-item"><a class="link" href="#our-story">Our Story</a></li>
<li class="menu-item"><a class="link" href="#services">Services</a></li>
<li class="menu-item"><a class="link" href="#tools">Tools of the Trade</a></li>
<li class="menu-item"><a class="link" href="#faqs">FAQs</a></li>
<li id="menu-item-310" class="menu-item"><a href="/category/blog/">Blog</a></li>
<li class="menu-item"><a class="link" href="#contact">Contact</a></li>
</ul></div>
The styling I have in the same file for the active CSS changes:
<style>
a, a:visited { color:black }
a.link.active { color:blue; }
</style>
And this is the script I have for the click events that change the color:
<script>
$(function() {
$('a.link').click(function() {
$('a.link').removeClass('active');
$(this).addClass('active');
});
});
</script>
I know a lot of this is really poorly done...so excuse me. I think if I could detect the currently visible section ID, and activate the CSS class of the menu item associated, it would be payday. Help!