Get browser window size using jQuery (useful for responsive web design)

I am sharing a very useful bit of code I use to get the window width when making responsive sites.

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>Get browser window size using jQuery (useful for responsive testing)</title>
<script src=""></script>
<script type="text/javascript">
var windowSize = $(window).width();
$('p.window-width').text('Window width = ' + windowSize + 'px');
var windowSize = $(window).width();
$('p.window-width').text('Window width = ' + windowSize + 'px');
<h1>Resize your browser window to get width:</h1>
<p class="window-width"></p>

view raw
hosted with ❤ by GitHub

Please comment below if you have any better solution.

Leave a Reply

Please note: These tutorials are meant to be helpful, but please note that I can not and will not be able to help with any implementations or modifications.

tl;dr If you do not understand it, hire me to do it.