Is there a way to change the color of the text 'test' in the class 't1' when it is clicked on? I would like both texts to change color even if only one is clicked. The texts are separated by another div for design purposes.
I appreciate your assistance!
<script>
function change(div){
if (div.style.color == "rgb(252, 198, 162)")
{
div.style.color="rgb(220, 20, 60)";
}
else
{
div.style.color="rgb(252, 198, 162)";
}
}
</script>
<div class="t1" style="color: rgb(252,198,162);" onclick="change(this);">
<p>test</p>
</div>
<div class="t2" style="color: rgb(252, 198, 162);" onlcick="change(this);">
<p> test </p>
</div>
<div class="t1" style="color: rgb(252,198,162);" onclick="change(this);">
<p>test</p>
</div>