jQueryオブジェクトが持つDOM要素の最初のDOM要素の幅を返す。paddingは含むがborderは含まれない。
windowやdocumentオブジェクトを対象にする場合は.width()を利用する。
サンプル
Javascript
var str = 'window : ' + $(window).innerWidth() + '/' + $(window).width() + '<br />';
str += 'document : ' + $(document).innerWidth() + '/' + $(document).width() + '<br />';
str += 'jqTest : ' + $('.jqTest').innerWidth() + '/' + $('.jqTest').width() + '<br />';
str += 'No Element : ' + $('.NoElement').innerWidth() + '/' + $('.NoElement').width();
$('.jqTest .screen').append(str);
$('.jqTest .targetBox').css({
padding: 20,
margin: 20,
border: '20px solid #990000',
background: '#CCCCCC'
}).click(function(){
alert('[innerWidth]' + $(this).innerWidth() + '[width]' + $(this).width());
});
HTML
<div class="jqTest">
<div class="screen"></div>
<hr />
<div class="targetBox">
ここの<br />
幅は?
</div>
</div>