hide/disaply button added
This commit is contained in:
@@ -1,13 +1,15 @@
|
|||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
showTable('build', buildings);
|
showTable('build', buildings);
|
||||||
let tableIsDisplayed = true;
|
let tableIsDisplayed = true;
|
||||||
tableVisibilityButton.addEventListener("click",()=>{
|
tableVisibilityButton.addEventListener("click", () => {
|
||||||
if(tableIsDisplayed){
|
if (tableIsDisplayed) {
|
||||||
|
clearTable('build')
|
||||||
}else{
|
tableVisibilityButton.innerHTML = "Показать таблицу";
|
||||||
showTable('build', buildings);
|
} else {
|
||||||
|
showTable('build', buildings);
|
||||||
|
tableVisibilityButton.innerHTML = "Скрыть таблицу";
|
||||||
}
|
}
|
||||||
|
tableIsDisplayed = !tableIsDisplayed;
|
||||||
} )
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -26,4 +26,11 @@ const showTable = (idTable, data) => {
|
|||||||
.enter()
|
.enter()
|
||||||
.append("th")
|
.append("th")
|
||||||
.text(d => d);
|
.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