Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript for changing background image depending on area user is in
    primarykey
    data
    text
    <p>My navigation has 5 buttons [Home, About, Services, Events, Contact] and each button has a background image of "blue-button.png". I want to switch it to "white-button.png" when the user is in that section. I wish it were as simple as a:active, but it's not and i'll explain why;</p> <p>All of the content is displayed in an overlay. The way the website is built, you never leave the index page, but the content is loaded into the index page. This is why the a:active doesn't work. </p> <p>Now for example, when the user opens the "About" page, the content (which I will call "About Main") appears, and has links to "About-Me", "About-You", and "FAQ". I want the "About" button to change background images (to white) whenever the user is in any of the areas that pertain to "About" (About Main, About me, About you, FAQ)... I also want the button to change back to blue when the user goes to a different section (EX: Contact) and then have the Contact button become white. </p> <p>The only way I've noticed to tell where the user is, is that the overlay they are on has a css style of <code>display:block</code> while all the others are hidden with <code>display:hidden</code>... <br><br></p> <p>So, I was thinking javascript similar to this:<br></p> <p><code>if</code> (About Main, About Me, About You, FAQ) is <code>display:block</code> <br> <code>{ $(".about").css('background-image', 'url(../img/white-button.png)' }</code> <br> <code>else</code><br> <code>{ $(".about").css('background-image', 'url(../img/blue-button.png)' }</code> <br></p> <p><code>if</code> (contact) is <code>display:block</code><br> <code>{ $(".contact").css('background-image', 'url(../img/white-button.png)' }</code> <br> <code>else</code><br> <code>{ $(".contact").css('background-image', 'url(../img/blue-button.png)' }</code> <br><br></p> <p>the navigation buttons have Classes like:<br> <code>&lt;a class="about"&gt;</code><br><code>&lt;a class="contact"&gt;</code><br><br> while the overlays have IDs like:<br> <code>&lt;div class="simple_overlay" id="about"&gt;</code><br><code>&lt;div class="simple_overlay" id="contact"&gt;</code></p> <p>I know it's a lot of information but hopefully someone can help me clear up the specifics, I'm not very good with javascript...<br> Heres <a href="http://www.heightsfamilyhealth.com/" rel="nofollow">a link to the site</a> if you want to look to get a better understanding </p> <p>Thank you so much for your time in advance, This one is really killing me!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload