CodeAPI

Node

Provides basic functionality for all Wix objects, including objects that are not elements.

Table of Contents

PROPERTIES

?
Store values associated with an object.
globalIndicates if an element appears on all pages or only on the current page.
idGets the elements's ID.
parentGets the element's parent element.
typeGets the element's type.

FUNCTIONS

?
Perform actions on an object.
scrollTo( )Scrolls the page to the element using an animation.

global

Indicates if an element appears on all pages or only on the current page.

Description

If global is true, the element appears on all pages.

If global is false, the element only appears on the current page.

Syntax

get global(): boolean
TYPE
?
The kind of data the property stores.
boolean
DEFAULT VALUE
?
The value of a property before you explicitly set it.
false

Examples

Get whether an element is displayed on all pages

let isGlobal = $w("#myElement").global; // false

id

Gets the elements's ID.

Description

The ID is the element's unique identifier. It is used when selecting elements using the $w() function.

An element's id is set in the Editor using the Properties panel.

Syntax

get id(): string
TYPE
?
The kind of data the property stores.
string

Examples

Get the ID

let myId = $w("#myElement").id; // "myElement"

parent

Gets the element's parent element.

Description

Some elements can contain other elements. This occurs when you drag an element onto a container element. The container is the parent of all the elements it contains.

Page, Header, and Footer are top-level elements and have no parent.

See Also

children

Syntax

get parent(): Node
TYPE
?
The kind of data the property stores.
DEFAULT VALUE
?
The value of a property before you explicitly set it.
null

Examples

Get the parent element and the parent's ID

let parentElement = $w("#myElement").parent;

let parentId = parentElement.id; // "page1"

type

Gets the element's type.

Syntax

get type(): string
TYPE
?
The kind of data the property stores.
string

Examples

Get the element's type

let myType = $w("#myElement").type; // "$w.Type"

scrollTo( )

Scrolls the page to the element using an animation.

Description

The scrollTo() function returns a Promise that is resolved when the animated scroll is complete and the element is now in view.

To scroll to a specific location on the page, see the wix-window scrollTo() function.

Calling the scrollTo() function on an element in a repeated item that is selected from the global scope causes an error.

Syntax

function scrollTo(): Promise<void>
RETURN VALUE
?
Value that a function evaluates to when it is finished running.
Promise<void>
Fulfilled - When the scroll is complete.

Examples

Scroll the page to an element

$w("#myElement").scrollTo();

Scroll the page to an element and log message when done

$w("#myElement").scrollTo()
  .then( ( ) => {
    console.log("Done with scroll");
} );