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
Solved

getElementsByTagName("li") change colour text and background

Posted on 2004-08-11
2
542 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
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
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…

860 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