The innerWidth() and innerHeight() methods in jQuery are used to get the computed inner width and inner height of the first matched element in a set. These methods include the content width and height along with padding but exclude borders and margins.
The innerWidth() method gets the computed inner width of the first matched element, including padding but excluding borders and margins.
The innerHeight() method gets the computed inner height of the first matched element, including padding but excluding borders and margins.
The results are then logged to the console using console.log(). Depending on the specific dimensions and styling of your <div>, you will see these values in the console when you inspect the page.
<html> <head> <title>inner Outer / Height Width</title> <style> div{ height: 150px; width: 200px; background:orange; padding: 10px; border: 5px solid red; margin: 10px; } </style> </head> <body> <div>Tutor Joes</div> <script src="js/jquery.js"></script> <script> $("document").ready(function(){ //Inner Height = element+padding console.log('InnerHeight : '+$('div').innerHeight()); console.log('InnerWidth : '+$('div').innerWidth()); //Outer Height = element+padding+border console.log('outerHeight : '+$('div').outerHeight()); console.log('outerWidth : '+$('div').outerWidth()); }); </script> </body> </html>
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions