Skip to content

event.preventDefault()

event.preventDefault — Events > Event object > Propagation and browser defaults. Cytoscape.js signatures, parameters and return contract.

event.preventDefault — Events › Event object › Propagation and browser defaults

Preview · Events › Event object › Propagation and browser defaults

Read in the complete API reference · All API members

// Prevent the original browser event's default behaviour when one is attached, for example page scrolling
event.preventDefault(): void

Prevent the original browser event's default behaviour when one is attached, for example page scrolling. This does not disable graph selection or dragging; use core controls such as autounselectify(), autoungrabify() and boxSelectionEnabled() for graph gestures.

Returns void

Example

event.preventDefault();
console.log(event.isDefaultPrevented()); // true

Example graph and handle setup