Why my vertical tab js code is refreshing the page continuously? [closed]

I had the same problem and didn’t find the answer. But I also find a solution without JavaScript. You can do tabs only with CSS+HTML.
It is something like:


CSS:

<style type="text/css">
        #tabs div
        {
            width: 200px;
            padding: 25px 0;
            margin: 0;
            position: relative;
        }

        #contents div
        {
            display: none;
            position: absolute;
            left: 200px;
            top: 0;
            width: 200%;
            margin-left: 20px;
        }

        #contents div:target
        {
            display: block;
        }
      //And add more features to make it pretty
    </style>

HTML:

<div id="tabs">
    <div id="menu">
       <ul>
           <li><a href="#1">Datos 1</a></li>
           <li><a href="#2">2</a></li>
           <li><a href="#3">3</a></li>
       </ul>
     </div>
     <div id="contents">
          <div id="1" class="tabcontent">1</div>
          <div id="2" class="tabcontent">2</div>
          <div id="3" class="tabcontent">3</div>
     </div>
     </div>


//Sería un ejemplo básico