Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138134

Change img src depending on class

$
0
0

When you use background to set img.

You can change the img by class

<img class=".png" style="background: url('test.png');">

.png{
    background: url('test2.png');
}

However when use src, is it possible to change the img by class?

<img src="test.png">

I think it is possible to change src by javascript, but if I can sort the things by class it is better to handle.

Is it possible?


Viewing all articles
Browse latest Browse all 138134

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>