10-25-2017 05:20
10-25-2017 05:20
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
Answered! Go to the Best Answer.
Best Answer10-25-2017 07:21
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
10-25-2017 07:21
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";
}
10-25-2017 07:21
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
10-25-2017 07:21
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";
}
10-25-2017 07:26
10-25-2017 07:26
perfect, works great! Thanks for the support.
Best Answer01-16-2019 13:09 - edited 01-16-2019 13:21
01-16-2019 13:09 - edited 01-16-2019 13:21
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