How to create tabs in a section of homepage to connect 3 different blogs contents?

4 0 0


I had three different topics of blogs (categorize with them as news, media, campaign) and I would like to put them in a section by switching tabs.

I tried to write the following simple code but no idea how to connect blog contents.

Note: I am using Expression theme which has a section can be added with customer HTML. Appreciate for any suggestion. Thanks.

<!DOCTYPE html>
<meta name="viewport" content="width=device-width, initial-scale=1">
body {font-family: Arial;}

/* Style the tab */
.tab {
  overflow: hidden;
  border: 1px solid #ccc;
  background-color: #f1f1f1;

/* Style the buttons inside the tab */
.tab button {
  background-color: inherit;
  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: #ddd;

/* Create an active/current tablink class */
.tab {
  background-color: #ccc;

/* Style the tab content */
.tabcontent {
  display: none;
  padding: 6px 12px;
  border: 1px solid #ccc;
  border-top: none;

<p>Click on the buttons inside the tabbed menu:</p>

<div class="tab">
  <button class="tablinks" onclick="openCity(event, 'News')" id="defaultOpen">News</button>
  <button class="tablinks" onclick="openCity(event, 'Media')">Media</button>
  <button class="tablinks" onclick="openCity(event, 'Campaign')">Campaign</button>

<div id="News" class="tabcontent">
  <p>connect to blog category news</p>

<div id="Media" class="tabcontent">
  <p>connect to blog category media</p> 

<div id="Campaign" class="tabcontent">
  <p>connect to blog category campaign</p>

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";
// Get the element with id="defaultOpen" and click on it