My webpage looks like that at the moment:
// Hover Function
$("#cats_image").mouseover(function() {
$("h1").text("Cats");
});
$("#dogs_image").mouseover(function() {
$("h1").text("Dogs");
});
$("#ducks_image").mouseover(function() {
$("h1").text("Ducks");
});
$("img").mouseout(function() {
$("h1").text("Animals");
});
// Click Function
$("#cats_image").click(function() {
$("h1").text("Cats");
$("footer div").removeClass("show");
$("#cats_text").addClass("show");
});
$("#dogs_image").click(function() {
$("h1").text("Dogs");
$("footer div").removeClass("show");
$("#dogs_text").addClass("show");
});
$("#ducks_image").click(function() {
$("h1").text("Dogs");
$("footer div").removeClass("show");
$("#ducks_text").addClass("show");
});
* {
margin: 0;
padding: 0;
font-family: sans-serif;
font-weight: normal;
}
header {
width: 100%;
}
main {}
img {
max-width: 200px;
cursor: pointer;
}
footer div {
display: none;
}
.show {
display: block;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<header>
<h1>Animals</h1>
</header>
<main>
<img id="cats_image" src="https://upload.wikimedia.org/wikipedia/commons/c/c4/Mackerel_tabby_cat_pair-Hisashi-01.jpg">
<img id="dogs_image" src="https://upload.wikimedia.org/wikipedia/commons/7/76/Two_puppies_dogs.jpg">
<img id="ducks_image" src="https://upload.wikimedia.org/wikipedia/commons/c/c8/The_pair_of_ducks.jpg">
</main>
<footer>
<div id="cats_text">Domestic cats are valued by humans for companionship and their ability to hunt rodents.</div>
<div id="dogs_text">The coats of domestic dogs are of two varieties: "double" being familiar with dogs (as well as wolves) originating from colder climates, made up of a coarse guard.</div>
<div id="ducks_text">Duck is the common name for numerous species in the waterfowl family Anatidae which also includes swans and geese.</div>
</footer>
The hover function looks perfect at first glance. But if you click for example one image, the title ("Cats", "Dogs", or "Ducks") should stay there, as long as you don't click another image. If you click in a white area (outside the images, and the text areas), it should look like nothing was clicked before (title: "Animals", and no footer text).
I tried a lot, and I am absolutely not sure how to go on. Could somebody help me please?