- jQuery - Home
- jQuery - Roadmap
- jQuery - Overview
- jQuery - Basics
- jQuery - Syntax
- jQuery - Selectors
- jQuery - Events
- jQuery - Attributes
- jQuery - AJAX
- jQuery CSS Manipulation
- jQuery - CSS Classes
- jQuery - Dimensions
- jQuery - CSS Properties
- jQuery Traversing
- jQuery - Traversing
- jQuery - Traversing Ancestors
- jQuery - Traversing Descendants
- jQuery References
- jQuery - Selectors
- jQuery - Events
- jQuery - Effects
- jQuery - HTML/CSS
- jQuery - Traversing
- jQuery - Miscellaneous
- jQuery - Properties
- jQuery - Utilities
- jQuery Plugins
- jQuery - Plugins
- jQuery - PagePiling.js
- jQuery - Flickerplate.js
- jQuery - Multiscroll.js
- jQuery - Slidebar.js
- jQuery - Rowgrid.js
- jQuery - Alertify.js
- jQuery - Progressbar.js
- jQuery - Slideshow.js
- jQuery - Drawsvg.js
- jQuery - Tagsort.js
- jQuery - LogosDistort.js
- jQuery - Filer.js
- jQuery - Whatsnearby.js
- jQuery - Checkout.js
- jQuery - Blockrain.js
- jQuery - Producttour.js
- jQuery - Megadropdown.js
- jQuery - Weather.js
jQuery - innerWidth( ) Method
Description
The innerWidth( ) method gets the inner width (excludes the border and includes the padding) for the first matched element.
Syntax
Here is the simple syntax to use this method
selector.innerWidth( )
Parameters
Here is the description of all the parameters used by this method
NA
Example
Following is a simple example a simple showing the usage of this method
<html>
<head>
<title>The jQuery Example</title>
<script type = "text/javascript"
src = "https://www.tutorialspoint.com/jquery/jquery-3.6.0.js">
</script>
<script type = "text/javascript" language = "javascript">
$(document).ready(function() {
$("div").click(function () {
var color = $(this).css("background-color");
var width = $(this).innerWidth();
$("#result").html("Inner Width is <span>" + width + "</span>.");
$("#result").css({'color': color, 'background-color':'gray'});
});
});
</script>
<style>
#div1 { margin:10px;padding:12px; border:2px solid #666; width:60px;}
#div2 { margin:15px;padding:5px; border:5px solid #666; width:60px;}
#div3 { margin:20px;padding:4px; border:4px solid #666; width:60px;}
#div4 { margin:5px;padding:3px; border:3px solid #666; width:60px;}
</style>
</head>
<body>
<p>Click on any square:</p>
<span id = "result"> </span>
<div id = "div1" style = "background-color:blue;"></div>
<div id = "div2" style = "background-color:pink;"></div>
<div id = "div3" style = "background-color:#123456;"></div>
<div id = "div4" style = "background-color:#f11;"></div>
</body>
</html>
This will produce following result −
jquery-css.htm
Advertisements