Solved

getElementsByTagName("li") change colour text and background

Posted on 2004-08-11
2
544 Views
Last Modified: 2008-03-06
Hi Experts

I am trying to change colour on a menu under <UL> <LI> as the mouse moves over and back to normal when it moves out, I can get it working when it moves over but no luck when it moves out, could you please help, PS i dont want to use ID's and I don't want to place it in a table...that just makes it too easy lol...Cheers

Here is my function

function li(ElementNumber,backcolor,textcolor)

       {

         document.getElementsByTagName("li")[ElementNumber].style.backgroundColor = backcolor;
         document.getElementsByTagName("li")[ElementNumber].style.color = textcolor;
         
       }

<DIV id="ul">
<ul>
  <li onmouseover="li(0,'white','gray')";onmouseout="li(0,'gray','white')">Armani</li>
  <li onmouseover="li(1,'white','gray')";onmouseout="li(1,'gray','white')">Oakley</li>
  <li onmouseover="li(2,'white','gray')";onmouseout="li(2,'gray','white')">Versace</li>
</ul>
</div>
0
Comment
Question by:baz_can_fix_it
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 50 total points
ID: 11780079
Hi

Have it like this:

  <li onmouseover="li(0,'white','gray');" onmouseout="li(0,'gray','white')">Armani</li>
  <li onmouseover="li(1,'white','gray');" onmouseout="li(1,'gray','white')">Oakley</li>
  <li onmouseover="li(2,'white','gray');" onmouseout="li(2,'gray','white')">Versace</li>

Regards,
Zyloch
0
 
LVL 1

Author Comment

by:baz_can_fix_it
ID: 11780120
Too easy...silly me...Thanx heaps mate

Cheers
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need help with this homework problem. 5 78
Error Handler 8 45
Json and ajax javascript 24 25
What is the valid CSS Selector Chain for this situation? 3 21
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question