-1

Is there any way I can get current html element dimensions (width/height) if they are not explicitly defined in CSS? Using just JavaScript? For example if I have image

var image = document.getElementsByClassName("top-image")[0];

And let's say I have click event. How can I get dimensions in the moment when event happened?

Boris Boskovic
  • 113
  • 2
  • 8

1 Answers1

1

image.getBoundingClientRect() More info here: https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect

mikkelrd
  • 413
  • 2
  • 10