1

My problem is that I need a width of an element and i get wrong result. I write in vue laravel. Here is the code:

this.timelineWidth = $('#timeline').width();
console.log(
     this.timelineWidth, 
     document.getElementById('timeline').offsetWidth, 
     document.getElementById('timeline')
);

The result from console: 861 861 <ol id=​"timeline">​…​</ol>​

When i check the element width myself it says it is 450px not 861. Do someone know what causes this? enter image description here

Also i tried to check the width from the console and the result is good enter image description here

  • 1
    document.getElementById('timeline').getBoundingClientRect().width – EugenSunic Dec 07 '20 at 22:38
  • 1
    Does this answer your question? [How do I retrieve an HTML element's actual width and height?](https://stackoverflow.com/questions/294250/how-do-i-retrieve-an-html-elements-actual-width-and-height) – EugenSunic Dec 07 '20 at 22:39
  • no its not working unless i put static width like 500px not 100%, then it work – PHPisMyPassion Dec 09 '20 at 17:50

0 Answers0