d3选择问题offsetParent为null
d3 selection issue offsetParent is null
我正试图使用d3选择获得offsetParent id(我以前有过类似的问题,但由于某种原因,答案在这里不起作用)。
当我控制台log d3.select(this)时,日志是:
[Array[1]]
0: Array[1]
0: g
offsetParent: div#divID
id: "divID"
如何从d3.select(this)开始获得id ?
我想做:
d3.select(d3.select(this).select("g").node().offsetParent).attr("id")
but get
Uncaught TypeError: Cannot read property 'offsetParent' of null
,当它不为空时。我一定选错了
g选择是导致问题的原因。这个选择:
d3.select(d3.select(this).node().offsetParent).attr("id")
为我解决了这个问题
相关文章:
- 数组在递归方法中设置为null
- 字符串在将其传递给另一个活动Android JavaScript时读取Null
- 无法获取属性'selectedIndex'的未定义引用或null引用
- Meteor方法在客户端返回null,在客户端运行的相同方法返回正确的值
- 来自文本输入null的html javascript变量
- delete在Object上效率低下,但在DOM Element's的数据属性,与null out相比
- php代码在textbox更改事件上显示null
- 相同的RegExp返回不同的结果-第一次是正确的结果,第二次是null
- 在php中提交数据时,如果某些值为null,而某些值为非null,如何进行查询
- 未捕获的类型错误:无法读取属性'addEventListener'的null chrome扩展名
- 为什么localStorage[“..”]未定义,而localStorage.getItem(“..”)为null
- ajax在输入等于null时进行检查
- html+javascript:如何在某些条件下禁用dropdownlist中的null选项
- 未捕获的类型错误:无法读取属性'状态'在react中为null
- contentWindow.document.body is null
- 在经过DATE验证的列中创建null值
- 为什么是文档.旧版应用程序中的DOM-object.properties为null
- if(foo!==null)的计算结果为true,即使foo为null
- php函数的ajax html$_POST值返回null
- d3选择问题offsetParent为null