I need to change the src of an image on mouse click using only css like
img:active {
} 1 answers
You can achieve this by using a element replacing the function content attribute.
Please note that you cannot set up any ARIA or other accessibility-related features using this technology, so the information you convey may be lost to parts of the user base. (This may be illegal depending on what the information is, who you are, and the control you are in/marketed to).
You may want to set tabindex or wrap the image in a button to make it accessible via keyboard/etc.
Also note that :active means "on click" not "after click". CSS has no "after click" pseudo-class (although :focus is sufficient in some cases).
img:active {
content: url(http://placekitten.com/200/200);
}
<img src="http://placekitten.com/g/200/200" alt="">
Hot tools Tags
Hot Questions
Popular tool
vc9-vc14 (32+64 bit) runtime library collection (link below)
Download the collection of runtime libraries required for phpStudy installation
VC9 32-bit
VC9 32-bit phpstudy integrated installation environment runtime library
PHP programmer toolbox full version
Programmer Toolbox v1.0 PHP Integrated Environment
VC11 32-bit
VC11 32-bit phpstudy integrated installation environment runtime library
SublimeText3 Chinese version
Chinese version, very easy to use
Hot Topics
20521
7
13634
4






