shell
shell

Reputation: 1937

d3 select offset parent

I am trying to get the offsetParent value from d3.select(this) -- (this is the container).

d3.select(this) returns:

[Array[1]]
   0: g
     offsetParent: div#divID

This is from the console.log() in chrome, each row is within the previous. How do I get this offsetParent div ID?

Preferably, I would like to do something like:

d3.select(this).select("g").select("offsetParent").attr("id")

Upvotes: 0

Views: 381

Answers (1)

Gilsha
Gilsha

Reputation: 14589

d3.select(this) returns the d3 selection. You will have to use d3.select(this).node() to get the dom element.

 d3.select(d3.select(this).select("g").node().offsetParent).attr("id")

Upvotes: 3

Related Questions