JS when hover off an element

I am using JS to add a class to an element when it is hovered over.

I also want to remove that class when the element is no longer hovered over.

How do you do this?

I also want to ensure it works on touch devices as well as with the mouse.

I don’t want to use jQuery (or any library).

With the touch devices (such as the ipad), some touch devices trigger the hover event when you first click, and then a second click on an item triggers the click event.

Can you give more details of your needs in respect to the touch devices?