https://www.w3schools.com/howto/howto_js_tabs.asp
DEMO
Tabs
Klik tombol di dalam menu tab:
KODE
fghgfjhgjhgjhgkhghkhParis
Paris is the capital of France.
Tokyo
Tokyo is the capital of Japan.
bbbbbb
hnmhnmhgfnm
hthfhfgh
hfjnghfnmjhgfnm
fghnmghm
fgnmgfnmgfnm.
<style>
body {font-family: Arial;}
/* Style the tab */
.tab {
overflow: hidden;
border: 15px solid #263545;
background-color: #263545;
}
/* Style the buttons inside the tab
.tab button {
background-color: #6a7a8a;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
font-size: 17px;
}*/
/* Change background color of buttons on hover */
.tab button:hover {
background-color: #263545;
}
/* Create an active/current tablink class */
.tab button.active {
background-color: #6a7a8a;
}
/* Style the tab content */
.tabcontent {
display: none;
padding: 6px 12px;
border: 15px solid #263545;
border-top: none;
}
</style>
<h2>Tabs</h2>
<p>Klik tombol di dalam menu tab:</p>
<div class="tab">
<button class="tablinks" onclick="openCity(event, 'kode')">kode</button>
<button class="tablinks" onclick="openCity(event, 'Paris')">Paris</button>
<button class="tablinks" onclick="openCity(event, 'Tokyo')">Tokyo</button>
<button class="tablinks" onclick="openCity(event, 'a')">a</button>
<button class="tablinks" onclick="openCity(event, 'b')">b</button>
<button class="tablinks" onclick="openCity(event, 'c')">c</button>
</div>
<div id="kode" class="tabcontent">
<h3>KODE</h3>
fghgfjhgjhgjhgkhghkh
</div>
<div id="Paris" class="tabcontent">
<h3>Paris</h3>
<p>Paris is the capital of France.</p>
</div>
<div id="Tokyo" class="tabcontent">
<h3>Tokyo</h3>
<p>Tokyo is the capital of Japan.</p>
</div>
<div id="a" class="tabcontent">
<h3>bbbbbb</h3>
<p>hnmhnmhgfnm</p>
</div>
<div id="b" class="tabcontent">
<h3>hthfhfgh</h3>
<p>hfjnghfnmjhgfnm</p>
</div>
<div id="c" class="tabcontent">
<h3>fghnmghm</h3>
<p>fgnmgfnmgfnm.</p>
</div>
<script>
function openCity(evt, cityName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " active";
}
</script>