How to select a d3 svg path with a particular ID

前端 未结 1 511
伪装坚强ぢ
伪装坚强ぢ 2021-01-07 21:48

I\'m working with d3. I create a globe of countries from a json file. The globe has svg paths, and each path has an id. I want to select a path with a particular ID. How wou

1条回答
  •  北荒
    北荒 (楼主)
    2021-01-07 22:35

    You can select an element by ID by prefixing the ID with "#" and using that as a selector:

    d3.select("#ID");
    

    or to select a path with that ID

    d3.select("path#ID");
    

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题