Shashank Garg
Shashank Garg

Reputation: 733

How can I access the nodes by Id in cytoscape.js?

cy.add([
        {group: "nodes", data: {id: "default"}, renderedPosition: pos},
        ]);

I want to access this node by id. and then change it's Id to something else. I tried accessing the node by $("#default").attr("id", nodeId );// where nodeId is a varaible.

It doesn't works as it is not an attribute of the node. How can I access this node?

Upvotes: 1

Views: 4711

Answers (1)

maxkfranz
maxkfranz

Reputation: 12240

ID is immutable in graphs. Consider edges are defined by their connecting nodes, and also consider compound nodes.

.attr() is not a function. And it looks like you're using jQuery rather than cy.js for searching. Please refer to the docs

Upvotes: 1

Related Questions