【发布时间】:2015-09-01 06:10:01
【问题描述】:
我正在尝试获取引导按钮的大小(宽度),但我有一些奇怪的行为。
<div class="row">
<div class="col-md-4 col-md-offset-4">
<button type="button" class="btn btn-warning btn-sm">
<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span> Save This Item
</button>
</div>
</div>
jquery
var siHeight = $('button').innerHeight();
var siWidth = $('button').innerWidth();
$('button').on('click', function() {
var iHeight = $('button').innerHeight();
var iWidth = $('button').innerWidth();
alert("On click H x W" + iHeight + " x " + iWidth + " Before click H x W " + siHeight + " x " + siWidth);
});
- innerWidth 在按钮点击事件之前或之后不相等
- 使用的每种浏览器(IE10、Firefox、Chrome)的行为都不同
我可以使用跨浏览器解决方案在单击事件之前和之后获得相同的大小吗? 谢谢
【问题讨论】:
标签: jquery css twitter-bootstrap cross-browser