var otd = document.createElement("td");我创建了这个td后怎样给这个td加colspan="2"?

解决方案 »

  1.   

    otd.setAttribute("colspan") = "2";
      

  2.   

    otd.setAttribute("colspan","2");刚才错了 
      

  3.   

    谢谢,如果要为table里加它呢,cellspacing="0" cellpadding="0"
      

  4.   

    table的对象获得后 可以参考用setAttribute()去添加
    比如tb.setAttribute("cellspacing","0");
      

  5.   

    加两个用什么隔开,tb.setAttribute("cellspacing","0" ,cellpadding="0");
      

  6.   

    js用setAttribute("attr","value"),
    利用其他的js库方便些…
      

  7.   

    调用两次setAttribute
    tb.setAttribute("cellspacing","0");
    tb.setAttribute("cellpadding","0");