How to get css property of dynamic table created by javascript?

This is javascript code for creating dynamic table it creates a crossword

function generateTable(range) {
    document.write("<table style='border: 1px solid black;'>");
    for (var a = 1; a < 10; a++) {
        document.write("<tr >");
        for (var b = 1; b < 10; b++) {
            if (a % 2 == 0 && b % 2 == 0) {
                document.write("<td style='border: 1px solid black;'><button style='width:50px; height:50px; background-color:black'></button></td>");
            } else {
                document.write("<td style='border: 1px solid black;'><button style='width:50px; height:50px; background-color:white' ></button></td>");
            }
        }
        document.write("</tr>");
    }
    document.write("</table>");
}

output is something like this
enter image description here

I want to count the n of black boxes with different function I have tried with getelementsbytagname() but it’s not working please help me with this

How to get css property of dynamic table created by javascript?