I'm trying to take the size (width) of a bootstrap button, but I have some strange behaviors.
<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);
});
- The innerWidth does not equal if taken before or after the button click event
- The behavior is different for each browser used (IE10, Firefox. Chrome)
Can I get the same size before and after the click event with crossbrowser solution ? Thanks
You will have to add some CSS to make the button not change when you click it:
Bootply of edited code with css