Having a small JS script that functions properly, but encountering an issue when quickly hovering over buttons causing the smooth transition effect to not work as desired. This abrupt change in image is quite unappealing.
Any help would be greatly appreciated.
var buttons = document.querySelectorAll("#section2_list li");
var div_img = document.getElementById('div_img');
buttons[0].addEventListener("mouseover", function() {
div_img.style.backgroundImage = "url(https://picsum.photos/id/237/200/100)";
});
buttons[1].addEventListener("mouseover", function() {
div_img.style.backgroundImage = "url(https://picsum.photos/id/238/200/100)";
});
#div_img {
width: 200px;
height: 100px;
transition: all 0.9s ease ;
}
<ul id="section2_list">
<li>one</li>
<li>two</li>
</ul>
<div id="div_img">
</div>