Skip to content

eles.getElementById(id)

eles.getElementById — Collection > Building and filtering. Cytoscape.js signatures, parameters and return contract.

eles.getElementById — Collection › Building and filtering

Preview · Collection › Building and filtering

Read in the complete API reference · All API members

// Find a member by id
eles.getElementById(id: string): Collection<NodeData, EdgeData, Data>

Find a member by id. This is a linear scan of the collection; use cy.$id( id) for the O(1) whole-graph index.

Parameters
NameDescription
id: string

the element id

Returns Collection<NodeData, EdgeData, Data>

a collection of one element, or an empty collection

Example

console.log(eles.getElementById('a').id()); // 'a'

Example graph and handle setup