我有一个页面,其中包含跨多个框架的大约 300 个链接。每个链接都有一个对应于至少一个其他帧中的 id 的 id。我正在编写一个脚本,将突出显示两个链接 onmouseover。目前,我可以更改两个链接的文本颜色(见下文)。我想将单个单词后面的背景颜色更改为黄色,以使文本看起来突出显示。
<html><head><title>Test</title>
<script>
function hey(id)
{document.getElementById(id).style.color = "red";
window.parent.frames["frame2"].document.getElementById(id).style.color = "red";}
function bye(id)
{document.getElementById(id).style.color = "black";
window.parent.frames["frame2"].document.getElementById(id).style.color = "black";}
</script>
</head>
<body>
<a id="1" class="word" onmouseover="hey(this.id)" onmouseout="bye(this.id)">hello</a>
<a id="2" class="word" onmouseover="hey(this.id)" onmouseout="bye(this.id)">world</a>....
</body></html>
如何更改链接的背景颜色,同时保持窗口的其余部分背景不变?