Вариант на jquery
<!DOCTYPE html >
<html>
<head>
<title></title>
<style type="text/css">
.parent {
}
.parent_current {
border: 1px solid red;
}
.child_current {
border: 1px solid green;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script type="text/javascript">
$(function() {
$(":button").click(function() {$("div.child_current").prevAll('.parent:first').toggleClass('parent_current'); })
});
</script>
</head>
<body>
<div class="parent"><a href="#">1</a></div>
<div class="parent"><a href="#">2</a></div>
<div class="parent"><a href="#">3</a></div>
<div class="parent"><a href="#">4</a></div>
<div class="parent"><a href="#">5</a></div>
<div class="child"><a href="#">5.1</a></div>
<div class="child_current"><a href="#">5.2</a></div>
<div class="child"><a href="#">5.3</a></div>
<div class="parent"><a href="#">6</a></div>
<div class="parent"><a href="#">7</a></div>
<input type='button' value='Go' onclick='Go()' />
</body>
</html>