LoginSignup
6
4

More than 5 years have passed since last update.

d3.jsでSVG要素の属性を取得する

Posted at

SVG要素の属性の設定方法は調べたらすぐ出てきますが、取得方法はなかなか見つからなかったのでまとめておきます。

設定方法

d3.select('svg').select('g').attr('id', 'example')

取得方法

// id = 'example'
var id = d3.select('svg').select('g').attr('id')

第2引数を指定しないだけで、指定属性の値を取得できます。

6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4