79102168

Date: 2024-10-18 12:58:59
Score: 1.5
Natty:
Report link

A less tedious method is to use the element.getBoundingClientRect as @Mehran Hatami mentioned.

Here's the code you need:

let elem = document.querySelector("<element>");
let rect = elem.getBoundingClientRect();
if(rect){
  const { width, height } = rect;
  console.log( width, height )
}
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Mehran
  • Low reputation (0.5):
Posted by: YSLdev