Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The contents of i and d are reversed in handling events callback function #266

Closed
Tyxiang opened this issue Oct 19, 2020 · 1 comment
Closed

Comments

@Tyxiang
Copy link

Tyxiang commented Oct 19, 2020

<!DOCTYPE html>
<html class="no-js">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
  <title>about</title>
  <script src="./d3.min.js"></script>
</head>

<body>
  <svg id="svg" version="1.1" xmlns="http://www.w3.org/2000/svg"></svg>
  <script>
    var data = "abc".split("");
    d3.select("body").selectAll("text")
      .data(data)
      .enter()
      .append("p")
      .text(function (d) { return d; })
      .on("click", function (d, i) {
        console.log(i);
      })
  </script>
</body>

</html>

a/b/c will be output.

@Tyxiang Tyxiang changed the title The contents of i and d are reversed in Handling Events Oct 19, 2020
@Fil
Copy link
Member

Fil commented Oct 19, 2020

@Fil Fil closed this as completed Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants