-
-
Save dbox/2369768 to your computer and use it in GitHub Desktop.
Display viewport width with jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Display your window width - useful for responsive web design | |
* @author: Rutger Laurman | |
*/ | |
// Ready? | |
$(function(){ | |
// Create debug element | |
$("body").append("<div style='position:absolute;top:0;left:0;border:1px solid #999;background:#eee;' id='viewportwidth'></div>"); | |
// Set contents on resizing window | |
$(window).resize(function(){$("#viewportwidth").html($(window).width());}); | |
// Trigger resize event | |
$(window).resize(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment