Javascript 生成只有一列的表

Javascript 生成只有一列的表,javascript,html,Javascript,Html,您好,我尝试生成一个只有一列的表。因此,我的链接只显示在一列中 以下是我的功能: function createTableForPdfFiles() { //To Create The Table var table = document.createElement("table"); table.setAttribute('id', 'pdfTable'); table.setAttribute('class', 'AA

您好,我尝试生成一个只有一列的表。因此,我的链接只显示在一列中

以下是我的功能:

    function createTableForPdfFiles() {

        //To Create The Table
        var table = document.createElement("table");
        table.setAttribute('id', 'pdfTable');
        table.setAttribute('class', 'AANTable');

        // insert Title Row
        var TitleRow = table.insertRow();
        var cell = TitleRow.insertCell(); 
        cell.setAttribute('class', 'AANTitleRow');
        cell.setAttribute('colSpan', pdfFiles.length + 1);
        cell.appendChild(document.createTextNode("Datenblätter"));

        //Insert Table Rows
        var pdfRow = table.insertRow();
        var cell = pdfRow.insertCell(); //Where the PDF´s are displayed
        cell.setAttribute('class', 'AANPdfRow');

        for (var i = 0; i < pdfFiles.length; i++) {
            var cell = pdfRow.insertCell();
            var link = document.createElement("a");
            link.setAttribute("href", "www.test.at" + pdfFiles[i].Link);
            var linktext = document.createTextNode(pdfFiles[i].Link);
            link.appendChild(linktext);
            cell.appendChild(link);
            cell.setAttribute('class', 'AANPdfCell');

        }

        $("#divTable").append(table);
}
函数createTableForPdfiles(){
//创建表的步骤
var table=document.createElement(“表”);
table.setAttribute('id','pdfTable');
table.setAttribute('class','AANTable');
//插入标题行
var TitleRow=table.insertRow();
var cell=TitleRow.insertCell();
cell.setAttribute('class','AANTitleRow');
cell.setAttribute('colSpan',pdfFiles.length+1);
cell.appendChild(document.createTextNode(“Datenblätter”);
//插入表行
var pdfRow=table.insertRow();
var cell=pdfRow.insertCell();//显示PDF的位置
cell.setAttribute('class','AANPdfRow');
对于(变量i=0;i
现在看来:

但我希望它看起来像:

那我怎么才能做到呢?我试图向表中添加另一行,但调试器说不支持。。。。。。任何帮助都会非常好


谢谢您的时间。

您必须为每个pdf创建一行

我必须把这个

var pdfRow = table.insertRow();
var cell = pdfRow.insertCell(); //Where the PDF´s are displayed
cell.setAttribute('class', 'AANPdfRow');
内部


看看这个->

只要从小提琴上复制并粘贴它,它就会像爆炸一样工作。