473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

problem using javascript to apply a color to an <li>

In the code below I can sucessfully target an <li> and change it's font size and font weight, but not color.

Am I missing something?

Javascript
Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3. //MOUSEOVER 
  4. function ChangeText(block, blockItem) {
  5.     if(block==0 && objCounter!=blockItem){    
  6.         document.getElementById("objectiveList").children[blockItem].className ="links_rolled"; 
  7.     }
  8. }
  9. //MOUSEOFF 
  10. function ChangeBack(block, blockItem) {
  11.     if(block==0 && objCounter!=blockItem){
  12.             document.getElementById("objectiveList").children[blockItem].className = "links_normal";  
  13.     }    
  14.  
  15. }
  16.  
  17.  
CSS

Expand|Select|Wrap|Line Numbers
  1.  
  2. .links_rolled{
  3. color: #33FF66;
  4. font-size:36px
  5. }
  6.  
  7. .links_normal{
  8. color:     #000000;
  9. font-size:10px
  10. }
  11.  
  12.  

As a newbie to using forums like this to ask questions, should I provide a link to the page? thanks for any help.
Mar 16 '11 #1

✓ answered by Rabbit

These are links? Link text color is defined by the following attributes.

Expand|Select|Wrap|Line Numbers
  1. a:link {color:#FF0000;}      /* unvisited link */
  2. a:visited {color:#00FF00;}  /* visited link */
  3. a:hover {color:#FF00FF;}  /* mouse over link */
  4. a:active {color:#0000FF;}  /* selected link */

3 1777
Rabbit
12,516 Expert Mod 8TB
These are links? Link text color is defined by the following attributes.

Expand|Select|Wrap|Line Numbers
  1. a:link {color:#FF0000;}      /* unvisited link */
  2. a:visited {color:#00FF00;}  /* visited link */
  3. a:hover {color:#FF00FF;}  /* mouse over link */
  4. a:active {color:#0000FF;}  /* selected link */
Mar 16 '11 #2
dgreenhouse
250 Expert 100+
As Rabbit alludes to, using CSS psuedo-classes is the most efficient method.
Plus, if JavaScript is disabled you still get the dynamic styling changes you're after.

See:
https://developer.mozilla.org/en/CSS/Pseudo-classes
https://developer.mozilla.org/en/Iss...-Element_hover
Mar 17 '11 #3
thanks for your reply. That's so obviously a better way to do this it's shocking. thanks!
Mar 17 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Timo Nentwig | last post by:
Hi! li { display: inline; } <li>foo bar</li> <li>blah</li>
8
by: Michael | last post by:
This is a two-part question to which I haven't been able to find an answer anywhere else. 1. Is it possible to format the bullet/number character of the <li>? In my styles sheet, I have the <li>...
4
by: Matt | last post by:
Hi, Got an unordered list with 100% width, with 5 list items of 20% width styled to fill the width of the container element. Renders fine in Mozilla, but when you change the size of the window...
5
by: Steel | last post by:
Hi at all, please consider this : <ul> <li><a>No link</a></li> <li><a href="#">This is a link</a></li> <li><a>No link</a></li> <li><a href="#">This is a link</a></li> .......................
4
by: abs | last post by:
Anybody has an idea how to get the <ul> element which is not nested in <li> element ? In other words I have several lists like this: <ul id="1"> <li>Aaaaaaaa</li> <li>Bbbbbbbb</li>...
2
by: Shaun | last post by:
Hello! I have a quick question regarding CSS and having it applied to all elements. I am trying to eliminate the gap between a paragraph and a list that usually occurs in html and I've found...
32
by: Mark | last post by:
Hi there I am using <li> tags for my menu. <ul> <li>item 1</li> <li>item 2</li> <li>item 3</li> </ul>
5
by: Syl | last post by:
Hello experts!! The top menu navigation bar displays perfectly in IE, but does not display properly in Mozilla or Netscape : http://checkeredshirt.com/textonly.html For some reason the non-IE...
10
by: BobaBird | last post by:
When <liis set to {max-width:45em;}, the bullets move from the top to the bottom of the <li>. Also, the bullet for a top-level <liends up on the same line as the last <liof its nested list, with...
1
by: Chinsu | last post by:
<html> <head> <style> #ex { width: 700px; background: red; float: left; } a, span { display: block;
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.