-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?

0

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.