-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #206 from creme332/aaa
minor improvements
- Loading branch information
Showing
7 changed files
with
96 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
function openTab(evt, tabName) { | ||
console.log("New tab = " + tabName); | ||
|
||
// hide all tab contents | ||
const tabcontents = [...document.getElementsByClassName("tabcontent")]; | ||
for (let i = 0; i < tabcontents.length; i++) { | ||
tabcontents[i].style.display = "none"; | ||
} | ||
|
||
// remove active class from the currently active tab link | ||
const tablinks = document.getElementsByClassName("tablink"); | ||
for (let i = 0; i < tablinks.length; i++) { | ||
tablinks[i].className = tablinks[i].className.replace(" active", ""); | ||
} | ||
|
||
// display content for clicked tab | ||
document.getElementById(tabName).style.display = "block"; | ||
|
||
// set active class only to the clicked tab link | ||
evt.currentTarget.className += " active"; | ||
} | ||
|
||
const tabs = ["Account", "Orders", "Settings"]; | ||
|
||
window.addEventListener("DOMContentLoaded", () => { | ||
[...document.getElementsByClassName("tablink")].forEach((tablink, i) => { | ||
console.log(i, tablink); | ||
tablink.addEventListener("click", (e) => openTab(e, tabs[i])); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters