Skip to content

Instantly share code, notes, and snippets.

@Ancientwood
Created March 4, 2021 11:50
Show Gist options
  • Save Ancientwood/aede992240da37f5b3aab802b21ba582 to your computer and use it in GitHub Desktop.
Save Ancientwood/aede992240da37f5b3aab802b21ba582 to your computer and use it in GitHub Desktop.
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