Webdev,
http://learn.javascript.ru/
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
.red {
background: red;
}
.green {
background: green;
}
.blue {
background: blue;
}
.yellow {
background: yellow;
}
.maroon {
background: maroon;
}
a{
width: 50px;
display: inline-block;
}
</style>
<script>
window.onload = function ()
{
var cls = 'red', obj = document.querySelector('.red'), main = document.querySelector('.main-nav');
main.onclick = function (event)
{
var el = event && event.target || window.event.srcElement;
if ("A" == el.tagName) {
var temp = el.className;
obj.className = temp;
el.className = 'red';
cls = temp;
obj = el;
}
}
}
</script>
</head>
<body>
<nav>
<ul class="main-nav">
<li><a class="red" href="#navTab1">1</a></li>
<li><a class="green" href="#navTab2">2</a></li>
<li><a class="blue" href="#navTab3">3</a></li>
<li><a class="yellow" href="#navTab4">4</a></li>
<li><a class="maroon" href="#navTab5">5</a></li>
</ul>
</nav>
</body>
</html>