document.getElementById("lorem").onsubmit = async (event) => {
// Prevent the default form submission behavior, which would reload the page
event.preventDefault()
// Get the currently selected element in the Designer
const el = await webflow.getSelectedElement()
if (el) {
await el?.remove();
} else {
console.log("No element is currently selected.");
}
}
Hi @toqeer.94! Do you mind providing a few details here?
Are you using v2 Designer APIs (should be dictated by the apiVersion in webflow.json)?
Do you mind testing to see if the remove() error is surfacing on other Webflow elements on your site? If not, do you mind providing more details around what kind of element is surfacing this error when you call remove()?
Thanks for the details @toqeer.94 - it looks like you may be using v1 of the Designer API. I would add the following in your webflow.json to use v2 Designer APIs (which will allow you to call .remove() on your selected element). This will inject the appropriate script in your app to utilize the newer APIs that correlate with the API docs. See more here: Migrating to v2