'How to use the :not selector in Cytoscape.js? (To select nodes that don't have an attribute)
I'm trying to use the :not selector in cytoscape.js. I want to select all nodes that don't have a specific attribute to open an context menu. E.g.:
cy.cxtmenu({
selector: not('node.selection'),
commands: [ .... ]
});
But I'm not sure how I can do this in cytoscape.js. Any help will be welcome.
Solution 1:[1]
Update in 2022:
In case you don't have control over the selector, but just want the opposite set, use this:
// initialize Cytoscape
let cy = cytoscape()
// select all and remove the rest
cy.$("*").not(cytoscapeSelector)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | byteSamurai |
