Attaching an element to the DOM

Figured this out. I just need to add the new element as a child to the selected element.

const parent = await webflow.getSelectedElement();
const child = webflow.createDOM("div");
child.setAttribute("myAttribute", "myValue");

parent.setChildren([child]);
await parent.save();
5 Likes