<style>
.container {
width: 100px;
height: 100px;
background-color: red;
}
</style>
<div class="container"></div>
<script>
const start = () => {
console.log('start');
document.addEventListener('mousemove', () => action('action'));
document.addEventListener('mouseup', end);
}
const action = (log) => {
console.log(log);
}
const end = () => {
console.log('end');
document.removeEventListener('mousemove', action);
document.removeEventListener('mouseup', end);
}
document.querySelector('.container').addEventListener('mousedown', start);
</script>