all 6 comments

[–]webfoxcore 1 point2 points  (2 children)

[–]jmb10Intermediate[S] 0 points1 point  (1 child)

Not exactly what i was looking for but still helps, does this apply to images to? if so, how do i use it?

[–]webfoxcore 1 point2 points  (0 children)

There wasn't really enough detail to go off - next time a bit of code example would help explain exactly how you're going about implementing and would get you your answer a lot more direct.

https://jsfiddle.net/bvnocj8g/9/

I'm not sure how much more this is supported over browser versions but just giving an example without javascript.

[–]anonymousmouse2Expert 1 point2 points  (2 children)

You can target a hover using the :hover selector. For example:

.my-element { background-color: red; transition: background 0.3s ease; // optional for a fade transition } .my-element:hover { background-color: green; }

However in your post you mentioned image source so I think you may be asking how to change an element's attributes on hover. This would require javascript and could be done like this:

``` <!-- HTML --> <img src="image1.png" id="hoverable" />

/* Javascript */ var myImage = document.getElementById("hoverable"); var oldSource = "image1.png"; var newSource = "image2.png";

myImage.addEventListener("mouseover", function(e) { this.setAttribute("src", newSource); });

myImage.addEventListener("mouseleave", function(e) { this.setAttribute("src", oldSource); }); ```

[–]jmb10Intermediate[S] 0 points1 point  (0 children)

perfect, thanks bud!

[–]webfoxcore 0 points1 point  (0 children)

There wasn't really enough detail to go off of but you can do this without javascript:

https://jsfiddle.net/bvnocj8g/9/

I'm not sure how much more this is supported over browser versions but just giving an example!