In my code, I want to use the transition only when the width turns wider. When the width decrease I don't want any animation. can I do with CSS only? Add/remove classes is not an option for me.
function changeCss() {
document.getElementById('squareId').style.width = "300px";
}
function reset() {
document.getElementById('squareId').style.width = "100px";
}
.square {
background-color: red;
width: 100px;
height: 100px;
transition: width 1s linear;
}
<div id="squareId" class="square"></div>
<button onclick="changeCss()">increase</button>
<button onclick="reset()">decrease</button>