Add and remove classes programmatically
See original GitHub issueI want to add and remove classes to a selected element, adding classes is working well, but removing them is not
var componentModel = editor.getSelected();
componentModel.addClass('form-color');
I want to be able to do
componentModel.removeClass('form-color');
But its throwing an error.
I’d be grateful if someone could share the correct syntax
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How To Remove a Class Name - W3Schools
Learn how to remove a class name from an element with JavaScript. Remove Class. Click the button to remove a class from me!...
Read more >React: Programmatically Add/Remove CSS Classes
This succinct, practical article shows you how programmatically add/remove CSS classes to/from an element in React.
Read more >javascript dynamically adding and removing classes [duplicate]
I am working on a simple example, if a user clicks on element then all the elements above it should have a class...
Read more >How to add/remove css class programmatically? - Mendix Forum
Hi Gatis,. I think widget ShowByCondition should help in your usecase! Adding classes is something most widgets and Mendix by default ...
Read more >How To Add Or Remove a Class With JavaScript - YouTube
In this tutorial, you'll learn how to add or remove a class on a HTML element using JavaScript. Get my free 32 page...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ll add
removeClass
in the next releaseLooking at https://github.com/artf/grapesjs/blob/dev/src/dom_components/model/Component.js#L276
I would say
removeClass
is not implemented. If you know the other classes I think you can dosetClass
with an array that don’t have the class you want to remove