Last active
July 20, 2017 08:21
-
-
Save svebal/00b2056204ba31f392134b96ddd516df to your computer and use it in GitHub Desktop.
display width of browser window in an element
This file contains 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
// store wrap div in a variable | |
$container = $( "body" ); | |
if ( $( "#special" ).length ) { | |
// element where we will display the document width | |
$documentWidth = $( '#curr_size' ); | |
// display document width in the container | |
$documentWidth.text( $container.width() + " px" ); | |
// fire event when window is resized | |
$( window ).resize( function(){ | |
// display document width in the container | |
$documentWidth.text( $container.width() + " px" ); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment