.test { border: 1px solid; cursor: pointer; height: 10px; position: relative; width: 100%; }
<div id="test1" class="test"></div>
I have displayed my HTML id
and its CSS. Now when I am doing $('#test').width()
I am getting 100
. I want its width
in pixels (not in %
).
Can anyone tell how to get its width in pixels?
One of options can be too, that parent element is not visible. Here is example: http://jsfiddle.net/nDMM3/
You can see, that jQuery return width = 100 (like 100%)
.test { border: 1px solid; cursor: pointer; height: 10px; position: relative; width: 100%; display:none; } #test2{ width:100%; } <div id="test1" class="test"> <div id="test2"> Hello </div> </div> alert($('#test2').width());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With