Skip to content

Instantly share code, notes, and snippets.

@svebal
Last active July 20, 2017 08:21
Show Gist options
  • Save svebal/00b2056204ba31f392134b96ddd516df to your computer and use it in GitHub Desktop.
Save svebal/00b2056204ba31f392134b96ddd516df to your computer and use it in GitHub Desktop.
display width of browser window in an element
// 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