I'm currently working on a layout for a page that features multiple titles in a row, each accompanied by a descriptive paragraph below. My goal is to have the paragraphs dynamically change based on which title the user hovers over. Additionally, I want each title to be displayed in a unique color, and for the font color of the paragraph text to match the corresponding title's color. However, I'm encountering difficulty in getting the paragraph text color to update accordingly.
Below is an illustrative example:
<script type="text/javascript">
function onover(caption) {
document.getElementById('text').innerHTML=caption;
document.getElementById('text2').innerHTML=caption;
}
</script>
<a onmouseover="onover('Paragraph 1')" style="color:green">Title 1</a>
<a onmouseover="onover('Paragraph 2')" style="color:red">Title 2</a>
</br>
<div id="text" style="color:green">Paragraph 1</div>
<div id="text2" style="color:red"></div>