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

switch class (style) dynamically

ANSWERED

Hi, I'm having a groupElement of lines, planing to have different style attributes for active/passive.
I probably could change their class by having different groupElements for each state and dynamically change the members...
But before I try that approach - is there a directer way like .toggle() or something similar?

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

This may help. Beware inconsistency between 'className' and '.class'.

I think I did some messing around with .class in widget-factory.

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
4 REPLIES 4

While I don't fully understand, you can change an element's .class at runtime. You could add or remove class names to that string and, in theory, the relevant styles would be displayed.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

hmmm... ok. I hoped so, but don't find the syntax. (I never had used classList so far and it doesn't seem to be supported?)
To explain better: I have a couple of lines and want them to have multiple classes (active passive) with different styles.
Then I want to switch the applied class (style) for some elements, but not for all (Instead of having 2 layers for bg and progress using just one )
Unfortunately I can't test in sim. It doesn't seem to take the changes I make

 

Best Answer
0 Votes

This may help. Beware inconsistency between 'className' and '.class'.

I think I did some messing around with .class in widget-factory.

Peter McLennan
Gondwana Software
Best Answer

oh great! yes!! that's exactly what I was looking for 😊
Need to have another look at the factory then... I'm so out of... 

Best Answer