Skip to content
Advertisement

Alter Image on mouseover and mouseleave

I have two arrays with the list of images name like this

JavaScript

I want to change the image in div tag with id="alter_img" on mouseover and mouseleave On mouseover it should be "arrow1.png" and on mouseleave it should be arrow_over1.png

Structure is like this

JavaScript

How could I do that?

Advertisement

Answer

Use data attributes:

HTML

JavaScript

jQuery

JavaScript
Advertisement