<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
div{
background-color: dodgerblue;
margin: 50px auto;
}
.box1{width: 50px; height: 300px;}
.box2{width: 120px; height: 600px;}
.box3{width: 400px; height: 200px;}
.box4{width: 300px; height: 150px;}
.box5{width: 700px; height: 234px;}
</style>
</head>
<body>
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
<div class="box4"></div>
<div class="box5"></div>
<script src="js/jquery-3.6.0.min.js"></script>
<script>
$("div").on("click", function() {
var a = $(this).is(":animated");
if(a === false){
var w = $(this).width();
var h = $(this).height();
$(this).stop().animate({
"width" : h,
"height" : w
})
}
})
</script>
</body>
</html>