Wrap and UnWrap function is not working in Grapesjs selected element
Question
if(data.component.get('tagName') === 'img') {
const selectedComponent = editor.getSelected();
const href = this.getHref();
const childHtml =`<a href="${href}"></a>`
$(`img#${selectedComponent.ccid}`).wrap(childHtml);
data.component.view.render();
editor.Modal.close();
}
Answers (1)
Related Questions and Answers
Continue research with similar issue discussions.
Issue #3461
Re-render trait on selected component
I know there is a function that can rerender the view of a trait. However, I still don't know how and where to use it.
Issue #2922
Get all css without specific component and it's children
Hi, so, in this issue #2861 we can get all the css of a selected element and it's children with: But if I want to get all the css but witho...
Issue #2308
Image is not resizing after creating a link for image
Issue #3363
Set content function empties the component content
I am trying to use the set function to change the content of a component, but actually the result is an empty component with nothing inside...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins β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.
Tutorial
Vanilla GrapesJS vs GrapesJS With Plugins: What You Actually Get Out of the Box (2026)
New to GrapesJS? See exactly what the stock editor gives you, where it falls short, and which plugins close the gaps β a beginner-friendly 2026 comparison
Tutorial
Lighthouse for GrapesJS: Audit Accessibility and SEO Without Leaving the Editor
Live WCAG 2.1/2.2 accessibility auditor + SEO manager for GrapesJS. Every finding is bound to the exact component β click to select, then one-click fix.
Tutorial
GrapesJS DevTools: A Developer Panel Inside Your Editor
If you've ever debugged GrapesJS with console.log(editor.getSelected()) and a dozen throwaway event listeners β this post is for you.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.