Search.../

collapse( )

Collapses the element and sets its collapsed property to true.

Description

The collapse() function returns a Promise that is resolved when the element's collapsed property has been set to true.

To learn about the behavior of a collapsed element, see the collapsed property.

You can also collapse an element when the page loads by using the Properties panel in the Editor.

Syntax

function collapse(): Promise<void>

collapse Parameters

This function does not take any parameters.

Returns

Fulfilled - When the element's collapsed property has been set to true.

Return Type:

Promise<void>

Related Content:

Was this helpful?

Collapse an element

Code Example

Copy Code
1$w("#myElement").collapse();
Collapse an element and log a message when done

Code Example

Copy Code
1$w("#myElement").collapse()
2 .then( () => {
3 console.log("Done with collapse");
4 } );
Toggle an element's collapsed state

Code Example

Copy Code
1if( $w("#myElement").collapsed ) {
2 $w("#myElement").expand();
3}
4else {
5 $w("#myElement").collapse();
6}