Get the width and height of document and window - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:height

Description

Get the width and height of document and window

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        var txt = "";
        txt += "Document width/height: " + $(document).width();
        txt += "x" + $(document).height() + "\n";
        txt += "Window width/height: " + $(window).width();
        txt += "x" + $(window).height();
        console.log(txt);
    });/*ww w.j  a  va2s.c  o m*/
});
</script>
</head>
<body>

<button>Display dimensions of document and window</button>

</body>
</html>

Related Tutorials