<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
<style>
#block2 {
/* visibility: hidden; */
display: none;
}
</style>
</head>
<body>
<div id="block1">test</div>
<div id="block2">text</div>
<a href="#" onclick="return switchBlock();">Click</a>
<script type="text/javascript">
function switchBlock() {
var el1 = document.getElementById('block2'),
el2 = document.getElementById('block1'),
st = el1.currentStyle ? el1.currentStyle.display : window.getComputedStyle( el1, null ).getPropertyValue('display');
if ( st == 'none' ) {
el1.style.display = 'block';
el2.style.display = 'none';
} else {
el1.style.display = 'none';
el2.style.display = 'block';
}
return false;
}
</script>
</body>
</html>