要素の座標を取得する関数について

getBoundingClientRect();

JavaScriptにて、要素の座標を取得したい場合はgetBoundingClientRect関数を使用する。
下にコード例を示す。

let coodinate = div.getBoundingClientRect();

プロパティ

  1. bottom
  2. height
  3. left
  4. right
  5. top
  6. width
  7. x
  8. y