Difference between $(window).width() vs $(document).width()

后端 未结 6 1026
灰色年华
灰色年华 2020-12-08 03:52

What is the major difference between $(window).width() vs $(document).width() in jQuery? Whether window denotes the browser and document represents

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-08 04:18

    $(window).width(); returns the width of browser viewport

    $(document).width(); returns width of HTML document

    $(document).width() is a bit unreliable, resulting in a lower value for a full-screened browser . $(window).width() is safer.

    $(window).width() gets the entire width of the window, including things like the scroll bar .

提交回复
热议问题