вот пример:
<html>
<head>
<style>
div
{
width: 50px;
height: 50px;
margin: 10px;
background-color: red;
}
</style>
</head>
<body>
<div></div><div></div>
<script type="text/javascript">
var divs = document.querySelectorAll('div');
divs[0].onclick = function () {
this.style.visibility = 'hidden';
divs[1].style.visibility = 'visible';
}
divs[1].onclick = function () {
this.style.visibility = 'hidden';
divs[0].style.visibility = 'visible';
}
</script>
</body>
</html>