width() method | Get Width of the Browser Window in Jquery

Date Published: 10/05/2020 Published By: JaiSchool

The predefined width() method in Jquery lets you know the width of the browser window.

<!DOCTYPE html>
<html>
<head>
  <title>Jquery width()</title>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>

<button>CHECK CURRENT WINDOW WIDTH</button>
<script>
$(document).ready(function(){
   $("button").click(function(){
   var width=$(window).width();
   alert("Width of the window is - "+width);
});
});
</script>

</body>
</html>

Publish A Comment

Leave a Reply

Your email address will not be published.