A
A
addd2015-11-20 14:00:37
HTML
addd, 2015-11-20 14:00:37

How to do image substitution using js?

There is an img when hovering over an img, another img should appear instead of the previous one, how to do this?
Can this be done without js?
If not, how to do it with minimal js.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xmoonlight, 2015-11-20
@addd

<img src="img.png" onHover='this.src="img_hover.png"' onMouseOut='this.src="img.png"'/>

A
Alexander Evgenievich, 2015-11-20
@banderos120

Do it with a div and change the background with :hover, or if you basically need an img, then wrap two img in one block (one img will have opacity: 0) and hang :hover on the block.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question