动态创建 DIV children 和 add/populate 它们的值

Dynamically create DIV children and add/populate their value

你能帮忙让它工作吗,我正在尝试动态创建元素

内部和 populate/add 到将从返回的 DIV 动态值的每个元素中数据库由服务器函数。也许有更好的方法来做到这一点?但是我不知道还有什么其他选择。

这是代码,但它不起作用,控制台显示错误(Uncaught TypeError: Cannot set 属性 'innerHTML' of null):

//This is the server side code that returns the data, it works fine, have checked it;
        function getReadyLine() {
            var rawData = sheetMAT.getRange(3, 2, sheetMAT.getLastRow() - 2, 5).getValues();
            for (var i = 0; i < rawData.length; i++) {
                if (rawData[i][3] === "A Ready Line" && rawData[i][4] === "ATY") {
                    temp1 = ' ' + data[i][0];
                    temp2.push(data[i][1], temp1);
                    dataReadyLine.push(temp2);
                    temp1 = '';
                    temp2 = [];
                }
            }
            return dataReadyLine;
        }

        //This is the client side code that should populate the innerHTML of the DIV template that is shown below;
        setInterval(function() {
            google.script.run.withSuccessHandler(function(data) {
                var temp3 = '';
                for (var i = 0; i < data.length; i++) {
                    temp3 = 'p' + data[i] + '/p';
                    document.getElementById("#item1").innerHTML = temp3;
                    temp3 = '';
                }
            }).getReadyLine();
        }, 10000);
    </script>

    //This is the DIV where I want to embed, display all the content/data returned from the server-side with the function getReadyLine();
    <div class="col-sm-3 col1">
        <h1 id="readyLine">Ready Line,
            <?= getCountReadyLine() ?> items</h1>
        <div class="item1" id="item1">
        </div>
    </div>

document.getElementById("#item1").innerHTML = temp3;

应该是:

document.getElementById("item1").innerHTML = temp3;

使用 getElementById() 函数时不应包含 #