The following code does not behave as I expect in spite of the use of transition
so there may be something I don't get about them.
Ideally, clicking on the button would append a child to the id2
div and make the id1
div grow smoothly accordingly.
$(function() {
$("#id1 button").click(() => {
$("#id2").append("<div class='child'>hehe</div>")
});
});
#id1 {
width: 100%;
transition: all 2 ease;
}
.child {
background-color: lemonchiffon;
min-height: 50px;
border: 1px solid rebeccapurple;
margin: 10px 0px;
}
#id2 {
padding: 20px;
border: 2px solid blue;
transition: all 0.5 ease;
}
<script src="https://code.jquery.com/jquery-3.4.0.min.js" integrity="sha256-BJeo0qm959uMBGb65z40ejJYGSgR7REI4+CW1fNKwOg=" crossorigin="anonymous"></script>
<div id='id1'>
<button>click</button>
<div id="id2"></div>
</div>