JS或者Jquery如何取得横向和纵向滚动条的最大可以滚动的值?

JavaScript011

JS或者Jquery如何取得横向和纵向滚动条的最大可以滚动的值?,第1张

需要准备的材料分别有:电脑、html编辑器、浏览器。

1、首先,打开html编辑器,新建html文件,例如:index.html,并引入jquery。

2、在index.html中的<script>标签,输入jquery代码:

$('body').append('height: ' + $(document).height() + '<br/>')

$('body').append('width: ' + $(document).width())

3、浏览器运行index.html页面,此时会打印出界面最大可以滚动的文档宽度和文档高度。

<!DOCTYPE HTML>

<html>

<head>

<meta charset=UTF-8 />

<title>Nothing</title>

<style type="text/css">

</style>

<script>

var create = function (x, y, text)

    {

    var marquee = document.createElement ('marquee')

    marquee.style.position = 'absolute'

    marquee.style.left = x + 'px'

    marquee.style.top = y + 'px'

    marquee.innerText = text

    document.body.appendChild (marquee)

    }

    

    window.onload = function ()

    {

    create (100, 100, "Look boddy, U got work harder and put yourself to the JavaScript, once U learn the heart of the JavaScript, I can guarantee U win.")

    }

</script>

</head>

<body>

</body>

</html>