Answer the question
In order to leave comments, you need to log in
How to calculate the dimensions of a js element?
There is an element on the page, I calculate the width and height of the element, multiply them. The resulting piece from the element (highlighted in red) I want to use in the future as a response zone for the script. Tell me how to hang a click event on half of this element (sq)?
<div class="el">
</div>
.el{
width: 800px;
height: 600px;
}
let el= document.querySelector('.el'),
w = el.offsetWidth * 0.5,
h = el.offsetHeight,
sq = w* h;
Answer the question
In order to leave comments, you need to log in
Options:
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question