Skip to content

cy.hasElementWithId(id)

cy.hasElementWithId — Core > Metadata and environment. Cytoscape.js signatures, parameters and return contract.

cy.hasElementWithId — Core › Metadata and environment

Preview · Core › Metadata and environment

Read in the complete API reference · All API members

// Whether an element with this id exists, via the O(1) id index — cheaper than getElementById( id).nonempty() because no handle is materialized
cy.hasElementWithId(id: string): boolean

Whether an element with this id exists, via the O(1) id index — cheaper than getElementById( id).nonempty() because no handle is materialized.

Parameters
NameDescription
id: string

the element id

Returns boolean

true when the graph holds that element

Example

console.log(cy.hasElementWithId('a')); // true

Example graph and handle setup