How to open multiple div-s, closing the old one?

Hello. There is a code.

<script type="text/javascript">
var show;
function viewdiv(id){
if( == "none") {
if(show) = "none"; = "block";
show = param;
}else = "none"

the <div>
<a href="javascript:void(0);" onclick="viewdiv('mydiv');"> unit 1</a>
the <div>
<a href="javascript:void(0);" onclick="viewdiv('mydiv2');"> block 2</a>
the <div>
<a href="javascript:void(0);" onclick="viewdiv('mydiv3');"> block</a>

the <div>
<a href="javascript:void(0);" onclick="viewdiv('mydiv');viewdiv('mydiv2');"> VSE </a>

<div id="mydiv" style="display:none;"> text 1</div>
<div id="mydiv2" style="display:none;"> text 2</div>
<div id="mydiv3" style="display:none;"> tЕЕ</div>

Need. That would be when the button is pressed vse opened the first and second div. (currently it opens the last one)
The main thing that has kept the old closing div s
April 3rd 20 at 18:50
1 answer
April 3rd 20 at 18:52
<a href="javascript:void(1);" onclick="viewdiv('mydiv1')">1</a>
<a href="javascript:void(1);" onclick="viewdiv('mydiv2')">2</a>
<a href="javascript:void(1);" onclick="viewdiv('mydiv3')">3</a>
<a href="javascript:void(1);" onclick="viewdiv('mydiv3')">4</a>
<a href="javascript:void(1);" onclick="viewdiv('mydiv3')">5</a>
<a href="javascript:void(1);" onclick="viewdiv('mydiv3')">6</a>
<a href="javascript:void(1);" onclick="viewdiv('mydiv3')">7</a> //
<a id="toggleLink" href="javascript:void(0);" onclick="viewdiv('mydiv1'), viewdiv('mydiv5')">
 Show 1 and 5
<div id="mydiv1" style="display:none;">1</div>
<div id="mydiv2" style="display:none;">2</div>
<div id="mydiv3" style="display:none;">3</div>
<div id="mydiv4" style="display:none;">4</div>
<div id="mydiv5" style="display:none;">5</div>
<div id="mydiv6" style="display:none;">6</div>
<div id="mydiv7" style="display:none;">7</div>

function viewdiv(id) {
 link = document.getElementById('toggleLink');
 el = document.getElementById(id);

 if ( == "block") { = "none";
 } else { = "block";

Find more questions by tags HTML