Issue #656✓ SolvedOpened December 18, 2017by michaellwatson3 reactions

Add and remove classes programmatically

快速解答by artf2

I'll add removeClass in the next release

Read full answer below ↓

Question

I 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

Answers (3)

👍 Most helpfulartfDecember 19, 2017

I'll add removeClass in the next release

michaellwatsonDecember 19, 2017

That worked great, thanks for your help :)

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Related tutorials

In-depth guides on the same topic.

All tutorials →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.