0

Given the following markup:

<a href="#" class="foo" style="display: block">Bar</a>

When I click Bar on the page, I'm expecting this code:

d3.select(".foo").on("click", () => {
  console.log(this.style.display);
);

to give the output: block.

However, I get:

Uncaught TypeError: Cannot read property 'display' of undefined

Thanks.

dbj44
  • 1,919
  • 2
  • 24
  • 45
  • Thanks Gerardo Furtado. Seems, there is a difference between `() => {}` and `function() {}`. – dbj44 Sep 16 '18 at 08:33
  • Yes, there is a huge difference between regarding `this`. Just use a regular function or, alternatively, the third and second arguments combined, as in the dupe targets. – Gerardo Furtado Sep 16 '18 at 09:44

0 Answers0