Search...
removeElement( )
Removes a widget element from the stage.
Description
The removeElement()
function returns a Promise that is resolved when the element is removed. You can only remove elements that are part of the widget with which the panel is associated.
The element selector is a string with the hash symbol (#
) followed by the ID of the item you want to select (for example, "#myElement"
). To use this function on an inner (nested) widget, use getScopedWixEditor()
.
Syntax
function removeElement(selector: string): Promise<void>
removeElement Parameters
NAME
TYPE
DESCRIPTION
selector
string
An element selector.
Returns
Fulfilled - when the element is removed.
Return Type:
Promise<void>
Related Content:
Was this helpful?
Use a toggle switch to remove/restore a widget element
Copy Code
1// In this example, we use a toggle switch to remove or restore an element in our widget.23import wixEditor from 'wix-editor';45$w.onReady(async function () {6 $w('#toggleSwitch').onClick(async (event) => {7 if (event.target.value) {8 await wixEditor.removeElement('#title');9 } else {10 await wixEditor.restoreElement('#title');11 }12 });13});