I don't have any Js as I am a beginner. I want when I click on a text it changes the color but when click other text change color and also return the previous text to the same color.
<div class="mt-5 first-member" onclick="document.getElementById('myImage').src='./assets/images/person-team.png'">
<span>
<small>
<sup>01</sup>
</small>
</span>
<h1> Alexandr Bruegel</h1>
</div>
<div class="mt-3 other-member" onclick="document.getElementById('myImage').src='./assets/images/bg-img.png'">
<span>
<small>
<sup>02</sup>
</small>
</span>
<h1>Ann Fowler</h1>
</div>
This code should work for you:)
document.querySelector('.mt-5').addEventListener('click',function(){
//document.getElementById('myImage').src='./assets/images/person-team.png'
document.getElementById('text1').style.color = 'red'
document.getElementById('text2').style.color = 'black'
})
document.querySelector('.mt-3').addEventListener('click',function(){
//document.getElementById('myImage').src='./assets/images/bg-img.png'
document.getElementById('text2').style.color = 'red'
document.getElementById('text1').style.color = 'black'
})
<div class="mt-5 first-member" >
<span>
<small>
<sup>01</sup>
</small>
</span>
<h1 id='text1'> Alexandr Bruegel</h1>
</div>
<div class="mt-3 other-member" >
<span>
<small>
<sup>02</sup>
</small>
</span>
<h1 id='text2'>Ann Fowler</h1>
</div>