Home >Web Front-end >JS Tutorial >jQuery's method of obtaining the width and height of document and window objects_jquery

jQuery's method of obtaining the width and height of document and window objects_jquery

WBOY
WBOYOriginal
2016-05-16 16:07:38962browse

The example in this article describes how jQuery obtains the width and height of document and window objects. Share it with everyone 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 will be helpful to everyone’s jQuery programming.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn