Reputation: 688
I have two stacked divs.
The outer div has a fixed width with overflow hidden.
The inner div has content that in total can be larger than the outher div.
How can I get the total width of the content of the inner div?
<div id='outer' style='width:100px'>
<div id='inner'>
content
</div>
</div>
When I try $('#inner').width() and the content is larger than outer, it will return the width of the outer div.
I am using Chrome.
Upvotes: 1
Views: 3688
Reputation: 3761
you can use .children()
jquery selector like this:
$('#info').html($('#box1').children().width();
$('#box2').children().width();
$('#box3').width());
Upvotes: 1
Reputation: 47
Try :
<div id="outer" style="width:100px">
<div id="inner">
<p id="content">content</p>
</div>
</div>
And
$('#content').width();
Upvotes: 1
Reputation: 5198
You can get the .scrollWidth
of the parent, which will return what you want.
document.getElementById('outer').scrollWidth
Upvotes: 4