var tdElement=document.getElementById("td_id"); tdElement.setAttribute("colSpan", "2"); //属性名 colSpan 要求 S 大写 //添加其他属性的时候同样需要大写第二个单词的第一个字母