Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
47
rated 0 times [  48] [ 1]  / answers: 1 / hits: 16998  / 14 Years ago, thu, september 16, 2010, 12:00:00

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?


More From » jquery

 Answers
76

To get the width of the invisible portion, simply subtract the total document width from the visible window width:



jQuery(document).width() - jQuery(window).width()


jsFiddle example



alt






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.


[#95611] Monday, September 13, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alejandro

Total Points: 231
Total Questions: 102
Total Answers: 107

Location: Jordan
Member since Wed, Jun 17, 2020
4 Years ago
alejandro questions
Mon, Jul 18, 22, 00:00, 2 Years ago
Fri, Sep 18, 20, 00:00, 4 Years ago
Thu, Sep 10, 20, 00:00, 4 Years ago
;