.buttons,
.weChangeColor {
width: 50%;
height: 100%;
float: left;
}
.weChangeColor p {
background: red;
border: 1px solid;
}
.toggleColor {
background: green;
}
<div class="buttons">
<p><a href="#">FirstLink</a></p>
<p><a href="#">SecondLink</a></p>
<p><a href="#">ThirdLink</a></p>
</div>
<div class="weChangeColor">
<p>FirstPara</p>
<p>SecondPara</p>
<p>ThirdPara</p>
</div>
By clicking on the links above, I want each corresponding paragraph to change its background color to green dynamically using JavaScript.
I am looking for the JavaScript code that will achieve this functionality.
If possible, jQuery can also be used to accomplish this task.