Set height of any element using JQuery

Virendradugar
Posted by Virendradugar under jQuery category on | Views : 26061
Below code will set/overwrite the width of dvWidth element using JQuery. You can download the Jquery from http://docs.jquery.com/Downloading_jQuery.

<script type="text/javascript" src="Script/jquery-1.3.2.js"></script>

<script type="text/javascript">

$(document).ready(function(){

$("#dvWidth").height(500);

});

</script>


<div id="dvWidth" style="width:200px;height:50px">

<h1>Virendra Dugar</h1>

</div>


Enjoy..

Comments or Responses

Posted by: Suresh44t on: 12/24/2012 Level:Starter | Status: [Member] | Points: 10
<!DOCTYPE html>

<html>
<head>
<style>
body {background:#F1F1A8;}
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("p").append($("p").height()+" px");
$("div.divContainer").append($("div.divContainer").height()+" px");
$("div.document").append($(document).height()+" px");
$("div.window").append($(window).height()+" px");
});
</script>
</head>
<body>
<div>
<div class="document">Height of this document is: </div>
<div class="window">Height of this window is: </div>
<div class="divContainer">Height of this div container is: </div>
<p>Height of this paragraph is: </p>
</div>
</body>
</html>


Reference: http://www.codekhan.com/2012/12/how-to-get-height-of-any-element-using.html

Login to post response