The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 19, 2019, 05:22:01 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Changing The Style Of An Anchor  (Read 2069 times)
cdc
Expert
****
Offline Offline

Posts: 105


View Profile
« on: April 25, 2007, 10:07:46 AM »

When a user clicks on link A, I want the color of link B to change.

I figure I can do this with the following code:

Code:
document.getElementById('B').innerHTML = "<font color=#fff>Anchor Text</font>"

But this don't seem right...
Logged

Will code for food.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: April 25, 2007, 11:11:30 AM »

I'd tackle it by changing either the style directly, or by changing the underlying class.

Changing the style directly:

document.getElementById('theLinkID').style.color = '#ff0000';

Or, considering you had two different CSS classes named "styleA" and "styleB"...

alert(document.getElementById('theLinkID').className); // shows styleA
document.getElementById('theLinkID').className = 'styleB';

That orta doya...
/p
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!