selected content parent tag remove
See original GitHub issuehttps://github.com/artf/grapesjs/issues/906#issuecomment-381403858
I need to remove the html content from editor.getSelected(). Now I’m using,
var selectedContent = editor.getSelected();
selectedContent.set('content', '');
selectedContent.components(MYHTML);
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?
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
How to remove the parent element using plain Javascript
If you want to delete whatever is inside the <tr> tags, by clicking on the "Delete ...
Read more >Remove the parent Element of a Node using JavaScript
To remove the parent element of a node, select the child node and use the `parentElement` property to get access to the parent...
Read more >How to remove parent element except its child element using ...
Given an HTML document and the task is to remove the parent element except for its child element. Approach 1: Use contents() method...
Read more >.remove() | jQuery API Documentation
A selector expression that filters the set of matched elements to be removed. Similar to .empty() , the .remove() method takes elements out...
Read more >Element.remove() - Web APIs - MDN Web Docs
The Element.remove() method removes the element from the DOM.
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 FreeTop 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
Top GitHub Comments
Have you seen this #1077 answer by @artf I think it’s suited with your case.
I got the CSS too. By using
this.htmlEditor..getContent()
,this.cssEditor..getContent()
I get all the content properly. 😃. Thanks for your response @afdallah.