最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to get variable attribute in d3 - Stack Overflow

programmeradmin3浏览0评论

How do I return a specific attribute of a variable using 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.

Something like this?

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

How do I return a specific attribute of a variable using 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.

Something like this?

d3.select("body").on("mouseover", function(){ 
    if (d3.select(this).attr("id") == "correct") {
        enableInteraction(d3.select(this));
    }
});
Share Improve this question edited May 3, 2012 at 19:34 ZachB 15.4k5 gold badges65 silver badges93 bronze badges asked Apr 25, 2012 at 3:53 AmyunimusAmyunimus 1,6334 gold badges21 silver badges44 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 22

Yes. Select this and then use the usual functions to access properties.

发布评论

评论列表(0)

  1. 暂无评论