I've created the following document:
<g>
<path class=?"line" name=?"gene_1" stroke=?"#aec7e8" d=?"M10.47...">?</path>?
<path class=?"line" name=?"gene_2" stroke=?"#aec7e8" d=?"M10.47...">?</path>?
<path class=?"line" name=?"gene_3" stroke=?"#aec7e8" d=?"M10.47...">?</path>?
...
</g>
When I mouse over each path I want to append it last inside the svg:g
so it appears on top of the other lines, but I don't know how to properly select the parentNode
:
function onmouseover(d, i){
var current_gene_name = d3.select(this).attr("name"),
current_gene_pcp = d3.select(".line[name=" + current_gene_name + "]");
p1 = this.parentNode
p2 = current_gene_pcp[0].parentNode
p3 = current_gene_pcp[0][0].parentNode
//p.appendChild(this);
}
p1
works, but I wanted to make sure that this
is a .line
, so I preferred to use current_gene_pcp
, but p2
returns <html></html>
as the parent, even though p3
returns the proper <g></g>
. This last version seems like a bug waiting to happen. Is there a better way?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…