I have 7 images of 7 different characters next to each other, (in a row), and I want to add text below them, I want the text to change depending on the image I click.
Here is my code:
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="style.css">
<title>Cine</title>
</head>
<body >
<img class="personajes_edge"src="Imagenes/Personaje1.jpg" alt="">
<img class="personajes_edge"src="Imagenes/personaje2_edge.jpg" alt="">
<img class="personajes_edge"src="Imagenes/personaje3_edge.jpg" alt="">
<img class="personajes_edge"src="Imagenes/personaje4_edge.jpg" alt="">
<img class="personajes_edge"src="Imagenes/personaje5_edge.jpg" alt="">
<img class="personajes_edge"src="Imagenes/personaje6_edge.jpg" alt="">
<img class="personajes_edge"src="Imagenes/personaje7_edge.jpg" alt="">
<p>Lorem ipsum dolor sit amet </p>
</body>
</html>
2
Answers
Try this:
Store the desired text inside the IMG’s
alt
attribute (which is needed anyways for A11Y).On click, populate the description element from that
alt
attribute value: