【发布时间】:2013-12-23 06:40:06
【问题描述】:
我是 d3 的新手。我有这样的定义:
node = node.enter().append("circle")
.attr('id', function(d){ return d.id; })
.attr("class", "node")
.on('mouseover', mouseover_node)
.on("click", nodeClick);
现在在函数 nodeClick 中,我想访问具有特殊 ID 的节点(或圆)。我正在寻找可以像这样使用的东西:
for(var i=0;i<maxId;i++) {
d3.select(the node with id = i).do....
有人知道我该怎么做吗?
【问题讨论】:
-
试试 d3.select("#" + i)
-
它给了我这些错误: Uncaught SyntaxError: Failed to execute query: '#56' is not a valid selector.
标签: javascript jquery d3.js