JSFiddle - React, Tailwind, and code Playground

by shawn anderson

HTML

<button id="myButton">
clk
</button>

<div class="clr20">
</div>

<div id="bw">

</div>

CSS

#myButton{
  width:50px;
}

.clr20{
  clear:both;
  height:20px;
  }

JavaScript

// wait button length to be 80px
function waitForCondition(obj, len, callBack){	  
  window.setTimeout(function(){
    if(obj.width() >= len){
      callBack();
    }else{
      waitForCondition(obj, len, callBack);
    }
  },250);
}

$("#myButton").click(function(){
	var w=$(this).width();
  $(this).width( w+10 );
  $("#bw").html( w+10 +"<br>")
})

$(function(){	 
   var obj=$("#myButton");
	 waitForCondition( obj , 80, function(){
	 	alert("threshold met");
   }); 
});