Get resized height and width in JavaScript

Description

The following code shows how to get resized height and width.

Example


<!--from   w w  w . j  a  v  a2s . c o m-->

<html lang="en">
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/smoothness/jquery-ui.css" rel="stylesheet" />
<script type="text/javascript">
$(function() {
var resizeOpts = {
stop: reportNewSize
};
function reportNewSize() {
alert($(this).height() + " pixels high, and " + $(this).width() + " pixels wide");
}
$(".resize").resizable(resizeOpts);
});
</script>
</head>
<body>
<div class="resize">
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse auctor ligula vel odio. Nam et sem vitae nibh convallis euismod. Aenean vitae urna quis augue adipiscing hendrerit. Nam faucibus. Phasellus eros. Ut bibendum eros at nibh. Sed erat. Aenean id enim vitae leo aliquet rutrum. Mauris fringilla euismod orci. Morbi tempus purus eget felis. Sed dui eros, tempor id, iaculis vel, pretium eget, nunc. Pellentesque vehicula tincidunt arcu. Ut a velit. In dapibus, lacus vitae lobortis dictum, libero pede venenatis magna, eu sagittis nunc erat sed ante. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Phasellus est dolor, mollis congue, ullamcorper eu, auctor ut, augue.</div>
</div>
</body>
</html>

Click to view the demo

The code above generates the following result.

Get resized height and width in JavaScript