jQuery gets the width and height of the document and window objects
- 2020-05-19 04:06:12
- OfStack
This example shows how jQuery gets the width and height of document and window objects. Share with you for your reference. The details are as follows:
<!DOCTYPE html>
<html>
<head>
<script src="js/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();
alert(txt);
});
});
</script>
</head>
<body>
<button>Display dimensions of document and window</button>
</body>
</html>
I hope this article has been helpful to your jQuery programming.