Skip to content

Selection

Inspect and change element selection and selectability.

#ele.selected()

// Whether the first element is selected
ele.selected(): boolean

Whether the first element is selected.

Returns boolean

true when selected

Example

console.log(eles.selected()); // false

Example graph and handle setup

#ele.selectable()

// Whether the first element may be selected by the user
ele.selectable(): boolean

Whether the first element may be selected by the user. The graph-wide cy.autounselectify() overrides this for user gestures.

Returns boolean

true when selectable

Example

console.log(eles.selectable()); // true

Example graph and handle setup

#eles.select()

// Select every selectable element, emitting select for each one that changed
eles.select(): this

Select every selectable element, emitting a select event for each one that changed. Unselectable elements are skipped.

Returns this

this collection, for chaining

Example

const node = cy.getElementById('a');
node.select();
console.log(node.selected()); // true

Example graph and handle setup

#eles.unselect()

// Deselect every element, emitting unselect for each one that changed
eles.unselect(): this

Deselect every element, emitting an unselect event for each one that changed.

Returns this

this collection, for chaining

Example

const node = cy.getElementById('a');
node.unselect();
console.log(node.selected()); // false

Example graph and handle setup

Also spelled eles.deselect.

#eles.selectify()

// Make these elements selectable
eles.selectify(): this

Make these elements selectable.

Returns this

this collection, for chaining

Example

const node = cy.getElementById('a');
node.selectify();
console.log(node.selectable()); // true

Example graph and handle setup

#eles.unselectify()

// Make these elements unselectable
eles.unselectify(): this

Make these elements unselectable. Does not deselect them; call unselect() for that.

Returns this

this collection, for chaining

Example

const node = cy.getElementById('a');
node.unselectify();
console.log(node.selectable()); // false

Example graph and handle setup

All guides · Alphabetical API index · Read continuously