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
How to Build an AI-Powered Page Builder with GrapesJS in 2026
What we learned building GJSDocs β from simple AI text generation to structured, context-aware visual editing
Tutorial
PageKit: the GrapesJS application you'd have to build anyway
A source-available Next.js app around the open-source GrapesJS core β publishing, custom domains, leads, checkout and a plugin loader.
Tutorial
Claude Skill for GrapesJS: How AI Is Changing the Way We Build Visual Editors
We've released the Claude Skill for GrapesJS Development β a free, open-source skill that turns Claude into a developer who actually knows GrapesJS
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.