- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
jQuery innerWidth() with Example
The innerWidth() method in jQuery is used to return the inner width of an element. The method includes padding, but the border and margin aren’t included.
Syntax
The syntax is as follows −
$(selector).innerWidth()
Example
Let us now see an example to implement the jQuery innerWidth() method −
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ document.getElementById("demo").innerHTML = "<br>Inner Width of DIV = " + $("div").innerWidth() }); }); </script> </head> <body> <h2>Demo Box</h2> <div style="height:150px;width:450px;padding:10px;margin:2px;background-color:green;"></div><br> <button>Inner Width of div</button> <p id="demo"></p> </body> </html>
Output
This will produce the following output −
Click the button to get inner width −
- Related Articles
- jQuery nextUntil() with Example
- jQuery change() with Example
- jQuery parentsUntil() with Example
- jQuery appendTo() with Example
- jQuery closest() with Example
- jQuery dblclick() with Example
- jQuery fadeOut() with Example
- jQuery find() with Example
- jQuery first() with Example
- jQuery focus() with Example
- jQuery click() with Example
- jQuery blur() with Example
- jQuery focusin() with Example
- jQuery finish() with Example
- jQuery addClass() with Example

Advertisements