Tagged: className; HTML; CSS; set attr;
- 2020-10-16 at 8:48 pm #34256eabrosiusNewbie
I am wondering if there is a way in Verge to apply/remove a CSS className to an HTML element in an additive/subtractive fashion.
Here is my setup:
I have a button with ID: “buttonA” and three CSS classNames called “default”, “selected”, and “unavailable”.
When the button needs to inherit the “default” className only, I am setting the className attribute to “default w-button”.
When the button needs to inherit both the “default” and the “selected” classNames, I am setting the className attribute to “default selected w-button”.
If I wanted to apply a third className to the button, like “unavailable”, I would have to set its className attribute to “default selected unavilable w-button”.
My question is this: can I apply and remove a className to a button without needing to know what other classNames the button is currently inheriting?
So instead of changing the className from “default w-button” to “default selected w-button”, can I just add the “selected” className to the button?
Attachments:You must be logged in to view attached files.2020-10-18 at 8:59 am #34273
- You must be logged in to reply to this topic.