日期:2014-05-16  浏览次数:20376 次

javascript小例子
获得tbody的所有tr结点:

//document.getElementById("tcpPortInfo").为Tr结点

    tbody = document.getElementById("tcpPortInfo").parentNode;

       var   trs   =   tbody.children;
           var i = 0;   
             for(var   j=0;   j<trs.length;   j++)  
               {

              alert(trs [i].nodeName)

              }

js设置TD的colspan:

         须注意colSpan的大小写.

             / /toptd.style.colSpan=3;

            // toptd.setAttribute("colSpan", "3");

js设置tag的背景色

          toptd.style.backgroundColor="#FF99FF"; 

js设置class属性:

     obj.className="123";