It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

How to script two arrays for a mouseover event?

How to script two arrays for a mouseover event?

Postby renzocj on Thu Sep 01, 2011 4:00 pm

I know this maybe sounds "newbie", perhaps I am still one.

I have 3 divs, all of them in a group "name", there are h1 tags inside them with names too. Well actually I have many many divs like this in several pages so I must use a JS sheet (.js).

Code: Select all
<div name="area"> <h1 name="stringRed"> Mercury </h1> </div>
<div name="area"> <h1 name="stringRed"> Venus </h1> </div>
<div name="area"> <h1 name="stringRed"> Earth </h1> </div>


The idea is to create an event for the divs, a mouseover event to a div in order to change the color of the words inside the h1 tags. When the mouse is over one particular div the word inside it must change to red.

I was trying this Java Script script:

(a cross-browser event handler present)

Code: Select all
function initialize ( ) {
aArea=document.getElementsByName("area");
aStringRed=document.getElementsByName("stringRed");

for (var i=0; i < aArea.length; i++) {
addEvent (aArea[i], 'mouseover', changeColor);
addEvent (aArea[i], 'mouseout', changeOutColor);
}
}

function changeColor() {
????
}
function changeOutColor() {
????
}


Thanks in advanced for any help
renzocj
 
Posts: 2
Joined: Thu Sep 01, 2011 3:51 pm

Who is online

Users browsing this forum: No registered users and 1 guest