I am working on a project for a company that showcases the four founders with their pictures displayed side by side. The requirement is to have the text under each image change dynamically based on which photo is clicked or hovered over. For example, when you click on "Mark", his name will be displayed in bold along with his qualifications. However, this information will be replaced once you click on "Kim" who is the next picture. As someone new to HTML, CSS, and JavaScript, this task is my first attempt at integrating all three languages.
I aim to style the text exactly as I desire, but I am struggling to find a way to update it in real-time. So far, I have only managed to print raw text. Is there a method to call a div to display the text and replace it with a new div upon clicking each image?
Instead of using .html("Mark does xyz"), could I potentially insert the entire "tr1" div with the updated button, heading, and paragraph?
<div id="trainers">
<h1><b>Meet Our Trainers</h1>
<img src="jackf.jpg" id="Mark" alt="Mark" width="17%" height="40%">
<img src="kimsond.jpg" id="Kim" alt="Kim" width="17%" height="40%">
<div id="tr1">
<h1><b><br>Mark</b></h1>
<p>Mark has been a personal trainer</p>
<a class="btn" href="#">Book With Mark</a>
</div>
<div id="tr2">
<h1><b><br>Kim</b></h1>
<p>Kim is a nutritionist</p>
<a class="btn" href="#">Book With Kim</a>
</div>
</div>
<script>
$('#Mark').click(function() {
});
$('#Kim').click(function() {
});
</script>