Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,31 @@ root.addEventListener("click", (event) => {
console.log(event.target.tagName);
console.log(event.target);
});

let table = document.querySelector("TABLE")
const addRowBtn = document.getElementById("add-row")
let rows = document.getElementsByTagName("TR")
let tdCount = rows[0].querySelectorAll("TD").length

addRowBtn.addEventListener("click", function addRow(){
let newRow = document.createElement("TR")

for (let i = 0; i < tdCount; i++)
newRow.appendChild(document.createElement("TD"))

table.appendChild(newRow)

})
function fillUnclrdCells(){
console.log("🟡 fillUnclrdCells triggered");
const cells = document.querySelectorAll("td");
const selectedClr = document.getElementById("colorSelector").value;

cells.forEach(cell=>{
if(!cell.style.backgroundColor||cell.style.backgroundColor === "white" ){
cell.style.backgroundColor = selectedClr;
}
});
}
document.getElementById("fill-grid").addEventListener("click", fillUnclrdCells);