![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hello, I would like to swap the color of a text item when a js function is called. --------------------------------------------- function swap(id) { green = '#00f000'; red = '#f00006'; if (document.getElementById(id).style.color == green) document.getElementById(id).style.color = red; else document.getElementById(id).style.color = green; } ----------------------------------------------- This looks easy, doesn't it ? The affectation is OK : document.getElementById(id).style.color = green; // This works But the test doesn't : if (document.getElementById(id).style.color == green) // alaways false |
|
When I try : alert(document.getElementById(id).style.color) I got an empty string... |
|
I don't know how to get the color value. Thank you for your help. |
#3
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |