views:

70

answers:

3

I can't use JQuery sadly I need to use good old Javascript.

I have a forum and a black theme and when people use black text on it you can't see it. So I want to use javascript to change all the black text on the page to white when the page loads.

+3  A: 
document.body.style.color = '#555555'

of course then you have to use the getElementByIdfunction instead of body if you want to select a specific element.

That's not really smart though. Go with CSS.

dierre
+1  A: 

Other answerers have posted JavaScript solutions if you really want to use JS for this, so I won't add another. However, I just thought I'd offer two alternatives:

  • If you find that black is the default color for any posts, and you can modify your theme, don't use JavaScript for this — open your theme's CSS file, try to locate the style that makes post text black, and change it to white.

  • If black text is simply caused by people changing the color to be such in their own posts, I think a better idea would be to just tell your members not to use black text. I can also see legitimate uses of black text on black backgrounds, e.g. for a lack of spoiler tags in your forum software.

BoltClock
A: 

If you mean you want to dynamically change your theme/styles you can use javascript to disable and enable css link element in the head by selecting link tags via document.getElementsByTagName("link")

Steve Mc