html代码如下
<table id="datatable-responsive" class="table table-striped table-bordered " width="100%">
<thead>
<tr>
<th style="width:20px">序号</th>
<th style="width:150px">申请事项(<font color="red"><%=snum%></font>)</th>
<th style="width:100px">企业名称</th>
<th style="width:100px">补齐时间</th>
<th style="width:100px">操作时间</th>
<th style="width:60px">事项状态</th>
<th style="width:40px">材料</th>
<th style="width:40px">补齐信息</th>
<th style="width:80px" id="excel3">操作</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>22</td>
<td>33</td>
<td>44</td>
<td>55</td>
<td>66</td>
<td>77</td>
<td>88</td>
<td>99</td>
</tr>
</tbody>
</table>
JS代码如下
$("#datatable-responsive").prop("outerHTML");
现在输出的是整个table的html,现在想过滤掉table里的某几列,网上找办法用过.not() .remove()等等一些方法都没其效果,请问这里的代码该如何写呢?谢谢了!
删除掉需要的列再获取outerHTML,隐藏或者设置visibility不可见都不行
//移除3,4列
var s = $("#datatable-responsive").find('tr').each(function (i, el) {
if (i == 0) $('th:gt(2)', this).filter(':lt(2)').remove()
else $('td:gt(2)',this).filter(':lt(2)').remove()
}).end().prop("outerHTML");
请把具体要过滤的内容写出来
第一,建议直接使用jqTable类的Jq插件
第二,jq的话,一个思路:用each遍历后,循环比较
$("tr:eq(index)")).hide();
index为你需要过滤的那一行的行号
删除掉需要的列再获取outerHTML,隐藏或者设置visibility不可见都不行
//移除3,4列
var s = $("#datatable-responsive").find('tr').each(function (i, el) {
if (i == 0) $('th:gt(2)', this).filter(':lt(2)').remove()
else $('td:gt(2)',this).filter(':lt(2)').remove()
}).end().prop("outerHTML");