IE 的 setAttribute 在针对某些属性(比如事件、集合)时是不起作用的。
td.className = "name"; // IE、Firefox 中均有效
td.setAttribute("className", "name"); // IE 中有效
td.setAttribute("class", "name"); // Firefox 中有效
同理:
td.colSpan = 3; // IE、Firefox 中均有效
td.setAttribute("colSpan", 3); // IE 中有效
td.setAttribute("colspan", 3); // Firefox 中有效
相关阅读