Helping ordinary people create extraordinary websites!

Go Back   Web Development Forum > Website Designing > HTML/CSS
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-10-2008, 11:07 PM
Junior Member
 
Join Date: Dec 2007
Posts: 3
Default Text/background color change

I am trying to switch the background and text colors of a table cell, using these two simple javascript functions. It works on the background color, but it doesn't change the text color as this always remains black. The initial cell background/text colors are set by CSS, and here too the text color remains unaffected. (It should be a dark blue background with white text).

What am I doing wrong? Thanks for any help given.

// CSS

Code:
table.links td
{
font: 12px Tahoma;
color: #ffffff;
font-weight: normal;
background-color: #000080;
}
// mouseover script

Code:
var changed_background = "#ffffff";
var changed_foreground = "#000080";

var normal_background = "#000080";
var normal_foreground = "#ffffff";

function change_background(tcell)
{
tcell.style.backgroundColor = changed_background;
tcell.style.color = changed_foreground;
}

function reset_background(tcell)
{
tcell.style.backgroundColor = normal_background;
tcell.style.color = normal_foreground;
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-11-2008, 02:37 AM
ryanhellyer's Avatar
Super Moderator
 
Join Date: Dec 2007
Posts: 632
Default

Welcome to the forum ineuw

I don't much about Javascript sorry so can't help.

But I am wondering what it you are trying to do? Presumably not just changing the table colour as you could just change the CSS to achieve that.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-11-2008, 11:30 AM
Junior Member
 
Join Date: Dec 2007
Posts: 3
Default Text/background color change

Quote:
But I am wondering what it you are trying to do? Presumably not just changing the table colour as you could just change the CSS to achieve that.
Hi ryanheller,

Thanks for the suggestion however, the text color settings don't work with CSS, even without javascript. All the javascript is supposed to do is to reverse the original colors set by the CSS when the mouse is over the cell, and reset the cell colors to their original when the focus changes.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-11-2008, 05:22 PM
Junior Member
 
Join Date: Dec 2007
Posts: 3
Default

Thanks for all your input. I found my error. 2 CSS classes were in conflict.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-12-2008, 03:32 AM
ryanhellyer's Avatar
Super Moderator
 
Join Date: Dec 2007
Posts: 632
Default

Good to hear you got it working
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 08:25 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.