Created
March 4, 2021 11:50
-
-
Save Ancientwood/aede992240da37f5b3aab802b21ba582 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let that; | |
class Tab{ | |
constructor(el){ | |
that = this; | |
this.main = document.querySelector(el); | |
this.button = document.querySelector("button"); | |
this.ul = document.querySelector("ul"); | |
this.lis = document.querySelectorAll("li"); | |
this.init(); | |
} | |
getRoot(){ | |
console.log(this.main); | |
} | |
init(){ | |
this.lis.forEach( li => { | |
li.onclick = function (li){ | |
this.style.display = "none"; | |
} | |
}); | |
this.button.onclick = this.addTab; | |
} | |
addTab(){ | |
var li = document.createElement("li"); | |
li.innerText = "ok"; | |
that.ul.appendChild(li); | |
} | |
} | |
var tab = new Tab("#tab"); | |
tab.getRoot(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment