I'm taking an online class on web languages and right now the class is trying to get the hang of JavaScript. I'm in so far over my head it isn't even funny. I hope there is someone out there who can help me understand this stuff. I have an assignment due on Tuesday and I no matter how I attempt to lay out the syntax, I can't seem to get the hang of it. As my reference material I'm using "JavaScript in easy steps" by Mike McGrath and Alexander J. Vincent's "JavaScript Developer's Dictionary." So here's what I'm trying to do. The assignment is to use JavaScript to access the objects via the DOM and change the attributes of that object. My project needs to showcase my ability (yeah right) to use event handlers to show or hide an element on a page. So I need to create one custom function to show or hide any element on the page triggered by an event handler. My page needs to use 3 different event handlers and one of those events needs to do at least two things. I'm trying to figure out how to use "onmouseover" to change the color of one div by forcing the substitution of another div with the exact same information except for the color info. So here's my most recent code on this: <div id="test1" style="position:absolute; background-color:red; border:'width:5px' 'color:blue'; top:10px; left:10px; width:150px; height:25px;"> <div id="test2" align="center" style="font-family:Ventana; color:blue;font-size:18px;"> Red </div> </div> <div id="test11" style="display:none; position:absolute; background-color:blue; border:'width:5px' 'color:blue'; top:10px; left:10px; width:150px; height:25px;"> <div id="test2" align="center" style="font-family:Ventana; color:blue;font-size:18px;"> Blue </div> </div> onmouseover="document.getElementByID('test11').style.display='block'; return:false"> The link for my assignment (as far as it has been done) is at www.montebateman.com/proj4/index.html Then I plan to allow the user to use onmouseclick to change the font color inside the div tags from white to black or black to white. I'm still scoping this out and might be able to figure this one out by myself--we'll see. Lastly I plan to activate three or four lines of the marquee text to begin scrolling in line by line using "onmouseout" (when the mouse is moved off the colorwheel). I'm also still playing with that one--trying to figure out the first one first, but I'm still no where near to making it work. I'm not looking for someone to do this for me. That won't help me in the long run, but I would like some guidance on syntax and coding choices and possibilities. Thanks in advance for all who are willing to help me get the hang of this.
Forcing the substitution of another div with the exact same information except for the color info is the long and unefficient option you have. Instead, just change the background of that particular DIV document.getElementByID('test1').style.background = "#f00"; // and use hex color codes instead of literal color names - it's safer Code (markup):