<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<button id="bt1">кнопка 1</button>
<button id="bt2">кнопка 2</button>
<button id="bt3">кнопка 3</button>
<div id="div1" style="width: 100px;height: 100px ;background: red" hidden="hidden">div1</div>
<div id="div2" style="width: 100px;height: 100px ;background: green" hidden="hidden">div2</div>
<div id="div3" style="width: 100px;height: 100px ;background: blue" hidden="hidden">div2</div>
<script>
function openElement(el) {
if(lastOpenEl){
lastOpenEl.hidden=true;
}
lastOpenEl=el
el.hidden=false;
}
let lastOpenEl;
let bt1=document.getElementById('bt1')
let bt2=document.getElementById('bt2')
let bt3=document.getElementById('bt3')
let div1=document.getElementById('div1')
let div2=document.getElementById('div2')
let div3=document.getElementById('div3')
bt1.onmousedown=()=>openElement(div1)
bt2.onmousedown=()=>openElement(div2)
bt3.onmousedown=()=>openElement(div3)
</script>
</body>
</html>