Creating Tabs using Html,css,js
Umapreethi Santhanakrishnan
Posted on January 24, 2021
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>
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.";
}
}
Through onclick event, pass the skill and if the skill matches the button value, update your innerHTML.
π πͺ π
π©
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.