| Author |
changing link background image dynamically
|
david arnold
Ranch Hand
Joined: Apr 10, 2009
Posts: 129
|
|
Hi,
I have a few links on a web page, each of link has a background image, i want to change the background image when the link is clicked , related code as below:
First, I tried to use javascript to change the link class(method 2), then I tried to change the link background image directly(method 1), I also tried to define the link active through css, all of them does not perform the task I need. Please help to figure out the problem.
Thanks.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56230
|
|
david arnold wrote:
document.getElementById(linkID).className = "title_link_error_no_select";
There is no such class in your (shown) CSS.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
david arnold
Ranch Hand
Joined: Apr 10, 2009
Posts: 129
|
|
oh, i forgot to to include that in the post, it is similar to the others except it has different background image.
Thank you.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56230
|
|
So, what's the next debugging step? For example, have you 100% verified that the expression document.getElementById(linkID) references the expected element?
And, you do realize that assigning to className replaces all other classes, right?
|
 |
david arnold
Ranch Hand
Joined: Apr 10, 2009
Posts: 129
|
|
Thank you Bear.
Yeah, document.getElementById(linkID) point to the right element, and I just tried
Which works, without the resetting the attribute innerHTML, both does not work. I do not know why.
I am not very sure if setting the className to that element will replace the old one, now I am sure after your informing .
Thanks.
|
 |
 |
|
|
subject: changing link background image dynamically
|
|
|