JSFiddle - React, Tailwind, and code Playground
by dezignas
HTML
<div class="width"></div>
CSS
.width {
width:200px;
height:200px;
background:red;
}
JavaScript
function somefunction (thewidth, sizeby ) {
var square = $(thewidth);
var width = square.width ();
var height = square.height ();
var ratio = width/height;
square.width(sizeby);
var width = square.width ();
square.height(width * ratio);
var height = square.height();
}
$(window).resize(function(){
var my = $(".width");
var my_heightas = $(window).width();
somefunction (my,my_heightas);
});