#7
.td_blue{background-color:#3982F7;}
111 | 222 |
333 | 444 |
555 | 666 |
function sel(i){
x=document.getElementById('cor_'+i)
if(i!=7){x.className="td_blue"}
}
var td_array=new Array();
var flag='td_flag';
var tdcol1="",tdcol2="",tdrow1="",tdrow2="";
function selTD(i)
{
i=i.toString();
if(flag!="td_flag"&&i!='join'){
tdcol2=i.substr(0,1)
tdrow2=i.substr(1,1)
}
if(flag=='td_flag'&&i!='join'){
tdcol1=i.substr(0,1)
tdrow1=i.substr(1,1)
flag=i
}
if(i=="join"){
doTab(tdcol1,tdcol2,tdrow1,tdrow2);
flag='td_flag';
}
}
function doTab(tdcol1,tdcol2,tdrow1,tdrow2){
if(tdcol1>tdcol2) {var temp=tdcol1;
tdcol1=tdcol2;
tdcol2=temp;
}
if(tdrow1>tdrow2) {var temp=tdrow1;
tdrow1=tdrow2;
tdrow2=temp;
}
x1=tdcol1-1;
x2=tdcol2-1;
y1=tdrow1-1;
y2=tdrow2-1;
if (x1==x2 && y1==y2) return;
htmlstr="";
xspan=0;
yspan=0;
for (i=x1;i<=x2;i++)
xspan+=tableId.rows[y1].cells[i].colSpan;
for (i=y1;i<=y2;i++)
yspan+=tableId.rows[i].cells[x1].rowSpan;
for (i=y1;i<=y2;i++) {
htmlstr+="
";
for(j=x1;j<=x2;j++){
if(tableId.rows[i].cells[j].innerHTML!=""){
htmlstr+=tableId.rows[i].cells[j].innerHTML;
}
}
}
htmlstr=htmlstr.substr(4);
for (i=y1;i<=y2;i++){
j=x1;
while (j
tableId.rows[i].deleteCell(x1);
j++;
}
if(xspan!=""){ tableId.rows[i].cells[x1].colSpan=xspan;}
}
for (i=y2;i>y1;i--){
tableId.rows[i].deleteCell(x1);
}
tableId.rows[y1].cells[x1].rowSpan=yspan;
tableId.rows[y1].cells[x1].innerHTML=htmlstr;
}
你试试看 选择变色后点击合并