Vovan6996,
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<script>
var show;
function setStyle(ids, display) {
ids.forEach(id => document.getElementById(id).style.display = display);
}
function viewdiv(...ids) {
if (show) {
if (show.toString() !== ids.toString()) {
setStyle(show, "none");
show = ids;
setStyle(show, "block");
} else {
setStyle(show, "none")
show = null
}
} else {
show = ids;
setStyle(show, "block");
}
}
</script>
</head>
<body>
<div>
<a href="javascript:void(0);" onclick="viewdiv('mydiv');"> блок 1</a></div>
<div>
<a href="javascript:void(0);" onclick="viewdiv('mydiv2');"> блок 2</a></div>
<div>
<a href="javascript:void(0);" onclick="viewdiv('mydiv3');"> блок 3</a></div>
<div>
<a href="javascript:void(0);" onclick="viewdiv('mydiv','mydiv2');"> VSE </a></div>
<div id="mydiv" style="display:none;"> text 1</div>
<div id="mydiv2" style="display:none;"> text 2</div>
<div id="mydiv3" style="display:none;"> text 3</div>
</body>
</html>