tb.setAttribute("cellpadding","10");
     tb.setAttribute("cellspacing","20");
     tb.setAttribute("bgcolor","red");
改成
     tb.setAttribute("style","cellpadding:10px; cellspacing:20px;background-color:red;");

解决方案 »

  1.   

    tb.style.backgroundColor="red";其它属性一样设置.
      

  2.   

    tb.setAttribute("cellpadding","10");
         tb.setAttribute("cellspacing","20");
         tb.setAttribute("bgcolor","red"); 这几行放在
    document.body.appendChild(tb);
    前面试试
      

  3.   

    tb.setAttribute("cellPadding","10"); 
    tb.setAttribute("cellSpacing","20"); 
    tb.setAttribute("bgColor","red"); 红色的字体将第2个单词首写字母大写就好了