JSFiddle - React, Tailwind, and code Playground
by Pavlo
HTML
<button style="width:50px">button1</button>
<button style="width:100px">button2</button>
<button style="width:120px">button3</button>
<button style="width:120px">button4</button>
JavaScript
var greatestWidth = 0; // Stores the greatest width
$(".mybutton").each(function() { // Select the elements you're comparing
var theWidth = $(this).width(); // Grab the current width
console.log(theWidth); //this is for checking
if( theWidth > greatestWidth) { // If theWidth > the greatestWidth so far,
greatestWidth = theWidth; // set greatestWidth to theWidth
}
});
$(".mybutton").width(greatestWidth); //finally setting the width