hide/disaply button added
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
showTable('build', buildings);
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
showTable('build', buildings);
|
||||
let tableIsDisplayed = true;
|
||||
tableVisibilityButton.addEventListener("click",()=>{
|
||||
if(tableIsDisplayed){
|
||||
|
||||
}else{
|
||||
showTable('build', buildings);
|
||||
tableVisibilityButton.addEventListener("click", () => {
|
||||
if (tableIsDisplayed) {
|
||||
clearTable('build')
|
||||
tableVisibilityButton.innerHTML = "Показать таблицу";
|
||||
} else {
|
||||
showTable('build', buildings);
|
||||
tableVisibilityButton.innerHTML = "Скрыть таблицу";
|
||||
}
|
||||
|
||||
} )
|
||||
tableIsDisplayed = !tableIsDisplayed;
|
||||
})
|
||||
|
||||
})
|
||||
@@ -26,4 +26,11 @@ const showTable = (idTable, data) => {
|
||||
.enter()
|
||||
.append("th")
|
||||
.text(d => d);
|
||||
}
|
||||
}
|
||||
|
||||
const clearTable = (idTable) => {
|
||||
const table = document.getElementById(idTable);
|
||||
while (table.children.length > 0) {
|
||||
table.removeChild(table.children[0]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user