Z
Z
zhrjnnrdzjj2021-07-03 15:53:12
css
zhrjnnrdzjj, 2021-07-03 15:53:12

How can I make the script apply to the element that the cursor is hovering over?

There are several elements on the page, and you need to change the style for the element that the cursor is hovering over.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2021-07-03
@Aetae

addEventListener('mouseover', ({target, relatedTarget}) => {
  if(relatedTarget) 
    relatedTarget.classList.remove('hover');
  if(target) 
    target.classList.add('hover')
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question