Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

changing text color issue

ANSWERED

Hi ppl,

 

I was trying to change the text color using an 'if statement' but I cannot get it to work. 

 

I tried creating 2 ‘class’ styles in my CSS and then used this to change between the two...

if (blah blah) {
test.class= "test-white";
} Else {
test.class= "test-black";
}

In the css I have the 'fill' property set to white for '.test-white' and black for '.test-black' but it does not do anything!?

 

I then tried using the classList.remove and classList.add methods but the debugging console reported the following: Cannot read property 'remove' of undefined. 

 

Is there a way to change the text formatting based on events? 

 

Thanks,

Steve

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

You can't currently change the className attribute. You could set the individual styles though.

if (blah) {
// mything.style.fill = "green";
} else {
// mything.style.fill = "red";
}

 

View best answer in original post

Best Answer
3 REPLIES 3

You can't currently change the className attribute. You could set the individual styles though.

if (blah) {
// mything.style.fill = "green";
} else {
// mything.style.fill = "red";
}

 

Best Answer

perfect, works great! Thanks for the support. 

Best Answer
0 Votes

As this thread is a little older now, I'd like to bring it up and ask the same question: With the new SDKs, is there a chance to change or add a class on an element? 

 

That could be actually quite useful in my case, where I'd like to change the position on some elements depending on a user's input. The clockface I'm working on should be compatible with the Versa and Ionic. Working with alternating classes could help to keep the code a lot cleaner. 

 

Thanks

Torsten

Best Answer
0 Votes