Skip to content

Instantly share code, notes, and snippets.

@aliaspooryorik
Created March 28, 2012 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aliaspooryorik/2225898 to your computer and use it in GitHub Desktop.
Save aliaspooryorik/2225898 to your computer and use it in GitHub Desktop.
Displaying document width with jQuery
// fire event when window is resized
$( window ).resize( function() {
$body = $( 'body' );
$documentWidth = $( '#document-width' );
if ($documentWidth.length===0){
$documentWidth = $( '<p id="document-width" />' );
$body.prepend( $documentWidth );
}
$documentWidth.text( $body.width() );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment