0

I have a mapping, with different colorful nodes linked together (or not) in d3.js. When a user clicks somewhere, it's either on nodes, on the links between the nodes or on the black background. What I would like is a way to get the color of the element I'm clicking, especially to know if it's outside the mapping, so a way to get "black" as a result (since the background is black).

const elems = document.body.getElementsByTagName("*");
const cssObj = window.getComputedStyle(elems, null);
let bgColor = cssObj.getPropertyValue("background-color");
console.log("The color clicked is : "+bgColor);

So far, this is the only code I've tested and I'm getting this error.enter image description here

I don't understand how this can come out. Help on this would really be appreciated I can't find anything. Also, here's what my mapping looks like.

enter image description here

Quentin
  • 65
  • 9

0 Answers0