I have 2 buttons with the same html structure on the same page. I have some js code to set the width depending on the text length of the button text. I need the js code to affect each individual button.
Please see the codepen here: https://codepen.io/gianpiero-di-lullo/pen/gOYxoVr
I've inserted them in an each() loop
$(".LIbtnWrapper").each(function(){
var frontW = $(".LIbtnFront h1").width(),
frontH = $(".LIbtnFront h1").height(),
backW = $(".LIbtnBack h1").width(),
backH = $(".LIbtnBack h1").height();
if(frontW > backW) {
$(".LIbtnBack h1").width(frontW);
} else {
$(".LIbtnFront h1").width(backW);
}
})
I expect each button to set their own frontFace and backface width based on their text length and also behave independently on mouse events