jQuery(document).width() doesn’t include the total width (viewable + outside of viewable when there’s a horizontal bar). It equals jQuery(window).width(). I thought jQuery(window).width() is the viewable area width and jQuery(document).width() is the total width.
How do I get the total width or how do I get the width of the area outside of the viewable area using jQuery?
To get the width of the “invisible” portion, simply subtract the total document width from the visible window width:
jsFiddle example
Like you write,
$(document).width()is the total width, and$(window).width()is the width that is currently visible.Tested in the latest Chrome, Firefox, Internet Explorer, and Safari.