как задать определённые значения куда будет перемещаться кнопка? JS

Сейчас кнопка при наведении может переместится за пределы видимой области

document.querySelector('#btn_no').addEventListener('mouseover', function() {
const position = {
    x: Math.floor(Math.random() * (window.innerWidth - this.offsetWidth)),
    y: Math.floor(Math.random() * (window.innerHeight - this.offsetHeight))
};
this.style.position = 'absolute';
this.style.top = position.x + 'px';
this.style.left = position.y + 'px';

});


Ответы (0 шт):