Skip to content

Instantly share code, notes, and snippets.

@jDramaix
Created October 20, 2012 13:09
Show Gist options
  • Save jDramaix/3923235 to your computer and use it in GitHub Desktop.
Save jDramaix/3923235 to your computer and use it in GitHub Desktop.
Dimension calculation with jQuery
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>GwtQuery</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.js" type="text/javascript"></script>
<style>
.innerDiv{
border: solid 1px black;
padding: 5px;
}
</style>
</head>
<body>
<div>An illustration how the jQuery works :</div>
<div id="view" style="display:none">
<div class="innerDiv" style="width: 300px;">
</div>
</div>
<p>
<div>innerDiv width: <span id="width"></span></div>
<div>innerDiv outerWidth: <span id="outerWidth"></span></div>
</p>
<script>
$("#width").text($(".innerDiv").width());
$("#outerWidth").text($(".innerDiv").outerWidth());
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment