Creating Tabs using Html,css,js

umapreethidev

Umapreethi Santhanakrishnan

Posted on January 24, 2021

Creating Tabs using Html,css,js

Fourth day of 100 days of code.

HTML Code:

 <div class="tabs">
      <button id="tab1" onclick="open(event, 'html')" type="button">
        HTML
      </button>
      <button id="tab2" onclick="open(event, 'css')" type="button">
        CSS
      </button>
      <button id="tab3" onclick="open(event, 'js')" type="button">
        JS
      </button>
    </div>
    <div id="cont"></div>
Enter fullscreen mode Exit fullscreen mode

Index.js

function open(event, skill) {
  event.preventDefault();

  const content = document.getElementById("cont");
  content.classList.add("content");
  if (skill == "html") {
    content.innerHTML =
      "HTML is the standard markup language for Web pages.With HTML you can create your own Website.";
  }
  if (skill == "css") {
    content.innerHTML =
      "CSS is the language we use to style an HTML document.CSS describes how HTML elements should be displayed.";
  }
  if (skill == "js") {
    content.innerHTML =
      "JavaScript is the worlds most popular programming language.JavaScript is the programming language of the Web.";
  }
}
Enter fullscreen mode Exit fullscreen mode

Through onclick event, pass the skill and if the skill matches the button value, update your innerHTML.

πŸ’– πŸ’ͺ πŸ™… 🚩
umapreethidev
Umapreethi Santhanakrishnan

Posted on January 24, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Infinite News Ticker πŸŽ‰πŸ˜
100daysofcode Infinite News Ticker πŸŽ‰πŸ˜

February 26, 2021

Animated skill bar using html,css,jquery
100daysofcode Animated skill bar using html,css,jquery

January 20, 2021

Javscript Age Calculator
100daysofcode Javscript Age Calculator

February 15, 2021

Creating Tabs using Html,css,js
100daysofcode Creating Tabs using Html,css,js

January 24, 2021

Day 2 of #100daysofcode
javascript Day 2 of #100daysofcode

October 28, 2020