How to select a d3 svg path with a particular ID

前端 未结 1 507
伪装坚强ぢ
伪装坚强ぢ 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)
提交回复
热议问题