这段时间做的东西比较邪门,连Javascript都用上了。为纪念受伤的心,特意将写的一段读table的代码记录一下。
1. 引入JQuery包
2.代码
var i,j
var col, row,cols,cols_old,rows,len,lp
var text
col = 0
row = 0
$(document).ready(function(){
len = $("#content").find("tr").length;
var arr = new Array(len);
var flag = new Array(len);
var index
var findex
for(lp = 0 ; lp < len ; lp++){
arr[lp] = new Array();
flag[lp] = new Array();
}
$("table[name='content']").find("tr").each(function(i){
$(this).find("td").each(function(j){
cols = $(this).attr("COLSPAN");
if("undefined" == typeof cols){
cols = 1
}
cols_old = cols;
rows = $(this).attr("ROWSPAN");
if("undefined" == typeof rows){
rows = 1
}
text = $(this).text();
row = i
//т?材???竚?ゼ恶?虫じ
index = -1;
do{
index = index + 1
}while(flag[row][index] == 'F') ;
col = index
do
{
do
{
arr[row][index] = text;
flag[row][index] = 'F'
cols = cols -1;
index = index + 1;
}while(cols > 0);
rows = rows - 1;
row = row + 1 ;
index = col ;
cols = cols_old
}while(rows > 0);
});
});
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/554557/viewspace-614933/
,如需转载,请注明出处,否则将追究法律责任。