jsp源码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>无标题文档</title> <script type="text/javascript" src="JQuery/jquery-1.10.1.js"></script> <script type="text/javascript"> $(document).ready(function() { var maxNum=0; var minNum=parseInt($(".red_one",this).eq(0).html()); $(".red_one",this).each(function() { var num = parseInt(this.innerHTML); if(num>maxNum) {maxNum=num;} if(num<minNum) { minNum=num; } }); alert(maxNum); alert(minNum); count = (maxNum-minNum)+1; $("<td>新增</td>").insertAfter(".red_one_fenxi"); /*for ( var i = 0; i < count; i++) { //$("tr").append($("<td>新增</td>")); $("<td>新增</td>").insertAfter(".red_one_fenxi"); }*/ }); </script> </head> <body> <table border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td> <table border="1" cellspacing="0" cellpadding="0"> <tr> <td class="issue" rowspan="2">期号</td> <td class="red" colspan="6">红球</td> <td rowspan="2" class="blue">蓝球</td> </tr> <tr> <td class="red">一</td> <td class="red">二</td> <td class="red">三</td> <td class="red">四</td> <td class="red">五</td> <td class="red">六</td> </tr> <tr> <td class="issue">2013080</td> <td class="red_one">01</td> <td class="red">04</td> <td class="red">10</td> <td class="red">13</td> <td class="red">21</td> <td class="red">31</td> <td class="blue">13</td> </tr> <tr> <td class="issue">2013081</td> <td class="red_one">04</td> <td class="red">13</td> <td class="red">14</td> <td class="red">20</td> <td class="red">22</td> <td class="red">30</td> <td class="blue">06</td> </tr> </table> </td> <td> <table border="1" cellspacing="0" cellpadding="0"> <tr> <td rowspan="2" bgcolor="#FF7F00" class="red_one_fenxi">一位</td> <!-- 在此处加入动态的列 --> <td class="fenxi" colspan="2">奇偶</td> <td class="fenxi" colspan="2">升降</td> <td class="fenxi" colspan="3">012路</td> <td class="fenxi" rowspan="2" bgcolor="#FF7F00">尾数</td> <td class="fenxi" rowspan="2">大</td> <td class="fenxi" rowspan="2">小</td> <td class="fenxi" colspan="3">012路</td> <td colspan="10">尾数分布</td> <td class="fenxi" rowspan="2" bgcolor="#FF7F00">振幅</td> <td class="fenxi" rowspan="2">升</td> <td class="fenxi" rowspan="2">降</td> <td class="fenxi"colspan="3">012路</td> </tr> <tr> <td>奇</td> <td>偶</td> <td>升</td> <td>降</td> <td>0</td> <td>1</td> <td>2</td> <td>0</td> <td>1</td> <td>2</td> <td class="fenxi">0</td> <td class="fenxi">1</td> <td class="fenxi">2</td> <td class="fenxi">3</td> <td class="fenxi">4</td> <td class="fenxi">5</td> <td class="fenxi">6</td> <td class="fenxi">7</td> <td class="fenxi">8</td> <td class="fenxi">9</td> <td>0</td> <td>1</td> <td>2</td> </tr> <tr> <td bgcolor="#FF7F00" class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi" bgcolor="#FF7F00"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td class="fenxi" bgcolor="#FF7F00"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> </tr> <tr> <td bgcolor="#FF7F00" class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi" bgcolor="#FF7F00"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td> </td> <td class="fenxi" bgcolor="#FF7F00"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> <td class="fenxi"> </td> </tr> </table> </td> </tr> </table> </body> </html>
问题:
我想在$("<td>新增</td>").insertAfter(".red_one_fenxi");这行代码中增加
$("<td colspan="count">新增</td>").insertAfter(".red_one_fenxi");
但是不成功,我的原意是,增加一个单元格并且跨count这么多的列,请问该怎么办
错误信息应该贴出来吧
没有错误信息呀!
你把第24行,换成$("<td colspan="count">新增</td>").insertAfter(".red_one_fenxi");
你看看,根本没有加入我想要的跨4列的单元格
@horse_leo:
写错了,应该rowspan
$("<td rowspan='"+count+"'>新增</td>").insertAfter(".red_one_fenxi");