Forum Moderators: open
<a href="http://example.com" onmouseover="fred.setAttribute('class','rolledover')">Hello</a>
<A id=fred name=fred href="http://example.com">Goodbye</A>
I tried a number of similar things... pointless to post them here since the don't work.....
Can anyone help?
<html>
<head>
<title>Test</title>
</head>
<body>
<style type="text/css">
.rolled{background-color:#0f0}
.normal{background-color:#f0f}
</style>
<a href="#" id="hello" class="normal" rel="rollover">Hi</a>
<a href="#" id="hello2" class="normal" rel="rollover">Hi</a>
<script type="text/javascript">
<!--
function roll(id,c)
{
var f=document.getElementById(id);
var s=document.getElementById((id.substr(id.length-1)=="2")?id.substr(0,id.length-1):id+"2");
f.className=c;
s.className=c;
}
var l=document.links;
var ll=l.length;
for(var i=0;i<ll;i++)
{
if(l[i].rel=="rollover")
{
l[i].onmouseover=function(){roll(this.id,"rolled");};
l[i].onmouseout =function(){roll(this.id,"normal")};
}
}
//-->
</script>
</body>
</html>