简体   繁体   English

如何在d3中获取变量属性

[英]How to get variable attribute in d3

How do I return a specific attribute of a variable using d3? 如何使用d3返回变量的特定属性?

For example, I want to select an element by mouseover, and pass on the selection to a function, but only if the element's id is a particular name. 例如,我想通过鼠标悬停选择一个元素,并将选择传递给一个函数,但id是元素的id是一个特定的名称。

Something like this? 像这样的东西?

d3.select("body").on("mouseover", function(){ 
    if (d3.select(this).attr("id") == "correct") {
        enableInteraction(d3.select(this));
    }
});

Yes. 是。 Select this and then use the usual functions to access properties. 选择this ,然后使用常用功能访问属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM