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 8863855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:05:31+00:00 2026-06-14T16:05:31+00:00

I am fairly new to JavaScript and I am trying to make it so

  • 0

I am fairly new to JavaScript and I am trying to make it so that when you mouseover a link, an image to the right of the page changes, then changes back on mouseout.

Here is my JavaScript:

function SwapOut(titleid){
if (titleid == video)
    document.getElementById("titleimg").src="images/videotitle.png"
else if (titleid == gamedesign)
   document.getElementById("titleimg").src="images/gametitle.png"       
else if (titleid == webdesign)
   document.getElementById("titleimg").src="images/webtitle.png"    
return true;
}

function SwapBack('titleid'){
if (titleid == home)
    document.getElementById("titleimg").src="images/hometitle.png"
else if (titleid == gamedesign)
   document.getElementById("titleimg").src="images/gametitle.png"   
else if (titleid == video)
   document.getElementById("titleimg").src="images/videotitle.png"  
else if (titleid == webdesign)
   document.getElementById("titleimg").src="images/webtitle.png" 
return true;
}

And my HTML:

<a id="eileenSmall1" href="video.html" onmouseover="SwapOut('video')" onmouseout="SwapBack('home')"></a>

<div id="title">
    <img src="images/hometitle.png" name="titleimg"/>
</div>

I would normally approach this with CSS but was having issues getting it to work as I am changing the properties of a different element. Any help would be 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-06-14T16:05:33+00:00Added an answer on June 14, 2026 at 4:05 pm

    1) Your trying to refer to an element with the id “titleimg”, yet you haven’t given the element an id at all.

    2) Your if condition doesn’t compare titleid with a string it compares it to what it thinks is a variable.. For example it should be 'video' not video.

    3) In your second function your parameter should be a variable not a string.. For example it should be SwapBack(titleid) not SwapBack('titleid').

    You should try this…

    JAVASCRIPT:

    function SwapOut(titleid){
    if (titleid == 'video')
        document.getElementById("titleimg").src="images/videotitle.png"
    else if (titleid == 'gamedesign')
       document.getElementById("titleimg").src="images/gametitle.png"       
    else if (titleid == 'webdesign')
       document.getElementById("titleimg").src="images/webtitle.png"    
    return true;
    }
    
    function SwapBack(titleid){
    if (titleid == 'home')
        document.getElementById("titleimg").src="images/hometitle.png"
    else if (titleid == 'gamedesign')
       document.getElementById("titleimg").src="images/gametitle.png"   
    else if (titleid == 'video')
       document.getElementById("titleimg").src="images/videotitle.png"  
    else if (titleid == 'webdesign')
       document.getElementById("titleimg").src="images/webtitle.png" 
    return true;
    }
    

    HTML:

    <a id="eileenSmall1" href="video.html" onmouseover="SwapOut('video')" onmouseout="SwapBack('home')"></a>
    
    <div id="title">
        <img src="images/hometitle.png" name="titleimg" id="titleimg" />
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm fairly new to JavaScript and I'm trying to access a page that requires
I'm fairly new to javascript and I'm trying to make an form for my
I'm fairly new to Javascript/JQuery. I'm trying to write an app that takes text
I'm fairly new to JavaScript and am trying to write some code that lists
I am fairly new to javascript and I am trying to make a second
I fairly new to JQuery and perhaps trying to achieve something that might be
First let me preface this question by saying that I'm fairly new to Javascript.
I'm fairly new to JQuery and Javascript in general. I don't think I'm trying
I'm fairly new to regular expressions in Javascript and I'm trying and failing to
I'm fairly new to jQuery and JavaScript, and I've been trying to implement a

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.