ドキュメント

CSS/innerWidth

From jQuery JavaScript Library

Jump to: navigation, search

« Back to CSS

innerWidth( )

Gets the inner width (excludes the border and includes the padding) for the first matched element.
This method works for both visible and hidden elements. It is not supported for elements that are indirectly hidden by consequence of a parent being hidden. Please use .width() for the window and document.
Examples:

Get innerWidth

var p = $("p:first");
$("p:last").text( "innerWidth:" + p.innerWidth() );

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  
  <script>
  $(document).ready(function(){
    var p = $("p:first");
$("p:last").text( "innerWidth:" + p.innerWidth() );

  });
  </script>
  <style>
  p { margin:10px;padding:5px;border:2px solid #666; }
  </style>
</head>
<body>
  <p>Hello</p><p></p>
</body>
</html>

NameType