Um hello everyone. I'm Emeralds and I'm still really new to Javascript, but while I was writing a quick script for something I'm working on, I encountered a problem and I'm not sure at all of what it is and how to fix it.
My script is in an external javascript file in a folder called js. I'm basically trying to get a title, tagline, and image to change (into different things) when the mouse is hovered over a variety of different elements.
For example, when the mouse is hovered over the first thumbnail, then the title, picture, and tagline (in a different element) will change.
This is the code I'm using:
Code:
// Pictures are stored in an array
if (document.images) {
img00= new Image
img01=new Image
img02=new Image
img03=new Image
img04=new Image
img00.src ="../images/start.gif"
img01.src="../images/1.gif"
img02.src="../images/2.gif"
img03.src="../images/3.gif"
img04.src="../images/4.gif"
img05.src="../images/5.gif"
}
function MouseOver()
{
document.getElementById("lformat-title… ="Changed title";
document.getElementById("lformat-tagli… = "Tagline Here";
document.getElementById("lformat-image…
}
function MouseOut()
{
document.getElementById("lformat-image… = img00.src;
document.getElementById("lformat-title… = "default title";
document.getElementById("lformat-tagli… = "default tagline";
}
In the HTML, when a <li> is hovered over, it will activate the mouseOver() and mouseOut() events.
Code:
<ul>
<li onmouseover="mouseOver()" onmouseout="mouseOut()">
<img src="images/thumbnail1.gif">
<p>Text here</p>
</li>
</ul>
And the thing that will be changed is this:
Code:
<h1 id="lformat-title">Example Title</h1>
<h2 id="lformat-tagline">Example Tagline</h2>
<img src="images/start.gif" />
The code isn't working when I load it up. The title and tagline change, but the images don't.
As I said, I'm still really new so I'd appreciate any help greatly!
Thankyou!
~Emeralds