To get and set the height of an html element, height()
method can be used. If we do not pass parameter value to the .height() method, it gets the current height of the element and if we pass parameter to the .height() method, it sets the parameter value as height of the element.
<script>
$("h1").css("background", "#c0c0c0").height("200px");
</script>
Above code snippet will first change the background color of the <h1> tag and then set the height of the “h1” tag to 200px.
<script>
alert($("h1").height());
</script>
Above code snippet will show the height of the “h1” element in JavaScript alert.
Views: 4823 | Post Order: 51