w3resource

jQuery CSS - Find the inner height and inner width of an element

jQuery CSS : Exercise-6 with Solution

Find the inner height and inner width of an element.

Test Data :

<body>
<div></div>
<p></p>
</body>

Solution:

HTML Code :

<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
  <meta charset="utf-8">
  <title>Find the inner height and inner width of an element</title>
<style>
  div {
    width: 90px;
    height: 75px;
    margin: 5px;
    background-color:#F3E2A9
  }
  p {
    margin-top:20px;
    padding: 5px;
    border: 2px solid #666;
  }
  </style>
</head>
<body>
<div></div>
<p></p>
 </body>
</html>

JavaScript Code:

$("p").text( "innerHeight:" +$("div").innerHeight()+" ::  innerWidth:" +$("div").innerWidth());

Live Demo:

See the Pen jquery-css-exercise-6 by w3resource (@w3resource) on CodePen.


Contribute your code and comments through Disqus.

Previous: Access the position of an element.
Next: Find the outerHeight and outerWidth of an element.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/jquery-exercises/jquery-css-exercise-6.php