David Gard
David Gard

Reputation: 12047

Get the complete width of a container that overflows off of the screen

How can I work out the full width of a container where the contents overflow off of the screen?

Here is an example of what I mean - http://jsfiddle.net/TFdLA/. In reality, .inner has no width set so takes up all of the available width on the screen.

However, if I use $('.inner').innerWidth(); I just get the width of the screen, where as what I would like is the width that .inner would take up if possible. Thanks

Upvotes: 1

Views: 61

Answers (2)

Monarch Wadia
Monarch Wadia

Reputation: 4976

It looks like your CSS file defines .inner{ width:300px }

Upvotes: 1

Nano
Nano

Reputation: 1398

Take a look at $('.inner')[0].scrollWidth or

$('.inner').each(function(){
    this.scrollWidth;
}) 

which is probably what you need.

Here with your fiddle

Upvotes: 1

Related Questions