<html>
<head>
<title>Highlight</title>
<style type="text/css">
.highlight { background-color:#ffff00; }
</style>
</head>
<body>
<div id="div1">Row one <a href="javascript:changeHighlight('div1');">HIGHLIGHT</a></div>
<div id="div2">Row two <a href="javascript:changeHighlight('div2');">HIGHLIGHT</a></div>
<div id="div3">Row three <a href="javascript:changeHighlight('div3');">HIGHLIGHT</a></div>
<input type="hidden" id="currentDiv" />
<script language="javascript" type="text/javascript">
function changeHighlight(myElement)
{
document.getElementById(myElement).className = 'highlight';
var lastHighlight = document.getElementById('currentDiv').value;
if(lastHighlight != '')
{
document.getElementById(lastHighlight).className = '';
}
document.getElementById("currentDiv").value = myElement;
}
</script>
</body>
</html>
UPDATE: This is OLD. You should look for a better solution.
No comments:
Post a Comment