$(document).ready(function() {
$.fn.widest = function() {
return this.length ? this.width(Math.max.apply(Math, this.map(function() {
return $(this).width();
}))) : this;
};
$('#formatButton').click(function(){
$('.buttons').widest();
});
});
Some Buttons To Format
<button class="buttons" >One</button>
<button class="buttons" >Two</button>
<button class="buttons" >Three Four Five</button>
<hr />
<button id="formatButton">
Format Them
</button>
body {
padding: 5px;
}
label {
font-weight: bold;
}
input[type=text] {
width: 20em
}
p {
margin: 1em 0 0;
}
External resources loaded into this fiddle: