Issue #2101💬 AnsweredOpened June 26, 2019by prabha-9121 reactions

Selected content parent tag remove

Quick answerby afdallah1

Have you seen this #1077 answer by @artf I think it's suited with your case.

Read full answer below ↓

Question

https://github.com/artf/grapesjs/issues/906#issuecomment-381403858 I need to remove the html content from editor.getSelected(). Now I'm using, While I use selectedContent.set('content', ''); it remove all the inner html. But didn't remove the parent tag. For example, Before: <h2 id="it4a"><p>Sample Update Check Done</p></h2> After: <h2 id="it4a"></h2> After set the components, its like <h2 id="it4a">NEW HTML</h2>. How to remove the parent tags while set the innerHtml empty? Guide me how to solve this?

Answers (3)

afdallahJune 27, 2019

Have you seen this #1077 answer by @artf I think it's suited with your case.

prabha-912June 27, 2019

Yeah I tried @afdallah, It returns indexOf undefined. Let me try again. Thanks for your response :)

prabha-912June 27, 2019

Hi @afdallah @artf I tried the above concept. It works fine in first time. While I try to update second time, it didn't work. indexOf

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.