HTML codes
<div id='container'>
container
</div>
addEventListener function
this function listens to an event that is passed through the first parameter
and calls a function that is passed through the second parameter
const container = document.getElementById("container");
function backgroundToRed(event) {
event.target.style.backgroundColor = 'red';
}
container.addEventListener('mouseover', backgroundToRed);
Top comments (0)