日期:2014-05-17  浏览次数:20739 次

jquery td遍历问题
<TABLE id=GridView1>
<TBODY >
<TR>
<TD>DKI</TD>
<TD>DATE</TD>
<TD>DKI</TD>
<TD>DATE</TD>
<TD>DKI</TD>
<TD>DATE</TD>
<TD>DKI</TD>
<TD>DATE</TD>
<TD>DKI</TD>
<TD>DATE</TD>
<TD>DKI</TD>
<TD>DATE</TD>
<TD>DKI</TD>
<TD>DATE</TD>
<TD>DKI</TD>
<TD>DATE</TD>
</TR>

<TR>
<TD>&nbsp</TD>
<TD>&nbsp</TD>
<TD>&nbsp</TD>
<TD>&nbsp</TD>
<TD>&nbsp</TD>
<TD>&nbsp</TD>
<TD>&nbsp</TD>
<TD>&nbsp</TD>
</TR>

<TR>
<TD>MKI</TD>
<TD>DATE</TD>
<TD>MKI</TD>
<TD>DATE</TD>
<TD>MKI</TD>
<TD>DATE</TD>
<TD>MKI</TD>
<TD>DATE</TD>
<TD>MKI</TD>
<TD>DATE</TD>
<TD>MKI</TD>
<TD>DATE</TD>
<TD>MKI</TD>
<TD>DATE</TD>
<TD>MKI</TD>
<TD>DATE</TD>
</TR>

<tr>
<TD>&nbsp</TD>
<TD>&nbsp</TD>
<TD>&nbsp</TD>
<TD>&nbsp</TD>
<TD>&nbsp</TD>
<TD>&nbsp</TD>
<TD>&nbsp</TD>
<TD>&nbsp</TD>
</tr>
</TABLE>
一共有88个 <TABLE>
我想把查询出来的字符串数字 在每个<TD>&nbsp</TD>按顺序输出,想问一下该怎么实现,用遍历的话该怎么写? 帮帮忙,这个比较急~谢谢大家了

------解决方案--------------------
HTML code

<table border="1">
            <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
        </table>
        <script>
            $("table td:contains(' ')").each(function(index, obj){
                $(obj).html("index" + index);
            });
        </script>

------解决方案--------------------
如果你有用过jquery:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script language="javascript" src="jquery-1.6.2.js"></script>换成你的版本
<script language="javascript">
$(function(){
$("#GridView1 td").each(function(index, element) {
alert($(element).text())的到的数据,你自己组装成你的
});
});
</script>
</head>

<body>
<TABLE id='GridView1'>
<TBODY >
<TR>
<TD>DKI</TD>
<TD>DATE</TD>
<TD>DKI</TD>
<TD>DATE</TD>
<TD>DKI</TD>
<TD>DATE</TD>
<TD>DKI</TD>
<TD>DATE</TD>
<TD>DKI</TD>
<TD>DATE</TD>
<TD>DKI</TD>
<TD>DATE</TD>
<TD>DKI</TD>
<TD>DATE</TD>
<TD>DKI