Please help me, i cannot get the width of an absolute position element with jquery. My element uses: height: 100%
and width: auto
via CSS.
I use $(element).width()
but obtain a 0.
Here is an example: http://codepen.io/anon/pen/LVjBvz
I need the element take the width of the inside image. This image has 4000x800px but i use width:100% and height:auto in css to have the image in fullscreen
Your code is executing before the image has a change to fully load. Use the
$(window).load(
to wait for it to complete:jsFiddle example
Ref: https://api.jquery.com/load-event/ and https://learn.jquery.com/using-jquery-core/document-ready/