Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7677777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:29:58+00:00 2026-05-31T17:29:58+00:00

I have nav code like this in my HTML file: <div id="center_links"> <ul> <li><a

  • 0

I have nav code like this in my HTML file:

<div id="center_links">
            <ul>
                <li><a href="#" onMouseOver="javascript:setSideText(1)">about</a></li>
                <li><a href="blog" onMouseOver="javascript:setSideText(2)">blog</a></li>

…and so on.

My JavaScript looks like this:

function setSideText(setting)
{
    if (setting == 0) // Home
    {
        document.getElementById('center_text').innerHTML = '<p><div class="dropcap">#</div>I am an information technology student interested in free and open source software.</p>';
    }
    else if (setting == 1) // About
    {
        document.getElementById('center_text').innerHTML = '<p><div class="dropcap">#</div>My name is David Gay, and this is my website. Welcome.</p>';
    }
    else if (setting == 2) // Blog
    {
        document.getElementById('center_text').innerHTML = '<p><div class="dropcap">#</div>My blog runs on the <a href="http://chyrp.net/">Chyrp</a> blog software.';
    }

When I mouseover a link, the side text on my page changes to describe the link. I want the text to change back to the default (setSideText(0)) when I’m not mousing over a nav link. I’ve been playing around with it for a bit now and I haven’t been able to figure it out.

I tried adding this to the JavaScript file, but to no avail:

document.getElementById('center_links').onMouseOut = setSideText(0);

I figured it wouldn’t work, anyway.

I’m sure there’s a simple solution that I’m not thinking of (I just picked up the language). Any guidance is appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:29:59+00:00Added an answer on May 31, 2026 at 5:29 pm

    I’d make two primary suggestions, the first: don’t use inline event-handlers (it’s more maintainable to have your behaviour in one place) and the second is to use onmouseout on the parent center_links element.

    To that end:

    function setSideText(setting) {
        if (setting == 0) // Home
        {
            document.getElementById('center_text').innerHTML = '<p><div class="dropcap">#</div>I am an information technology student interested in free and open source software.</p>';
        }
        else if (setting == 1) // About
        {
            document.getElementById('center_text').innerHTML = '<p><div class="dropcap">#</div>My name is David Gay, and this is my website. Welcome.</p>';
        }
        else if (setting == 2) // Blog
        {
            document.getElementById('center_text').innerHTML = '<p><div class="dropcap">#</div>My blog runs on the <a href="http://chyrp.net/">Chyrp</a> blog software.';
        }
    }
    
    var linksElem = document.getElementById('center_links'),
        links = linksElem.getElementsByTagName('a');
    
    for (var i = 0, len = links.length; i < len; i++) {
        links[i].dataIndex = i+1;
        links[i].onmouseover = function() {
            setSideText(this.dataIndex);
        };
    }
    
    linksElem.onmouseout = function(){
        setSideText(0);
    }
    

    JS Fiddle demo.


    Edited to amend the setSideText() function to respond to words rather than an index (because I think it’s easier for adding subsequent links at a later date and doesn’t rely on being able to add arbitrary attributes to the elements, though it does require that the element have an id attribute…):

    function setSideText(setting) {
        if (setting == 'home' || setting == 0)
        {
            document.getElementById('center_text').innerHTML = '<p><div class="dropcap">#</div>I am an information technology student interested in free and open source software.</p>';
        }
        else if (setting == 'about')
        {
            document.getElementById('center_text').innerHTML = '<p><div class="dropcap">#</div>My name is David Gay, and this is my website. Welcome.</p>';
        }
        else if (setting == 'blog')
        {
            document.getElementById('center_text').innerHTML = '<p><div class="dropcap">#</div>My blog runs on the <a href="http://chyrp.net/">Chyrp</a> blog software.';
        }
    }
    
    var linksElem = document.getElementById('center_links'),
        links = linksElem.getElementsByTagName('a');
    
    for (var i = 0, len = links.length; i < len; i++) {
        links[i].onmouseover = function() {
            setSideText(this.id);
        };
    }
    
    linksElem.onmouseout = function(){
        setSideText(0);
    }
    

    JS Fiddle demo.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple sidebar like this: <div class=sidebar> <ul class=nav> <li class=Page1><a href=Page1.html>Page1</a></li>
I have a html structure like this : <div id=nav_holder style=position:absolute;border-radius:400px;width:0px;height:0px;background-color:#460203;z-index:350px;> <div id=inner_wrap> </div>
I have html like this: <div> <span style=display: inline-block;height:20px>20</span> <span style=display: inline-block;><img src=img/ex.png/></span> </div>
I have a simple nav made up of the following HTML; <div class=inner> <div
I have a basic website nav layout that looks like this: <li class=folder parent_folder>
I have the following code: css: nav div:nth-child(1) { background: red; } nav div:nth-child(2)
a javascript+DOM question. Can someone improve my code? I have a page nav bar
I'm designing a navigation bar. The code looks like this: <nav class=menu> <ul class=topnav>
My internal css won't work with the little code I have. This seems like
I have the following Nav: <li id=categories> <ul> <li class=cat-item cat-item-8 current-cat><a href=#>Link</a> <ul>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.