let btn = document.getElementById('moveBtn'); let img = document.getElementById('backgroundImg'); btn.addEventListener('click', () => { img.style.left = "100px" })
#backgroundImg { position: relative; height: 100px; width: 100px; background-color: red; } .moveImage { display: flex; flex-direction: column; width: 200px; }
<div class="moveImage "> <img src="" alt="" id="backgroundImg"> <button id="moveBtn">Click</button> </div>
Aquí está el código, he usado backgroundcolor pero puedes usar la imagen de fondo