js中的table中需要获取勾选行的值(jquery)
<table width="100%" id="table1">
<thead>
<tr>
<th>序号</th>
<th>批次号</th>
<th>申请方</th>
<th>商户号</th>
<th>申请时间</th>
<th>源币种</th>
<th>状态</th>
</tr>
</thead>
<tbody>
<s:iterator id="batchNumberDto" value="#request.list">
<tr>
<td>
<s:if test="#request.sta==1">
<input type="checkbox" name="SerialNo" value="#batchNumberDto.batchNumber"/>
</s:if>
<s:else>
1
</s:else>
</td>
<td><s:property value="#batchNumberDto.batchNumber" /></td>
<td>
<s:property value="#batchNumberDto.merchantName" />
</td>
<td>
<s:property value="#batchNumberDto.userId" />
</td>
<td>
<s:property value="#batchNumberDto.createTime" />
</td>
<td>
<s:property value="#batchNumberDto.sourceCurrency" />
</td>
<td>
<s:property value="#batchNumberDto.merchantId" />
</td>
</tr>
</s:iterator>
</tbody>
</table>
<a οnclick="associate();return false;"
href="#">关联</a>
function associate() {undefined
var array = $("table input[type=checkbox]:checked").map(function () {undefined
/* return { "cell2": $.trim($(this).closest("tr").find("td:eq(2)").text()), "cell4": $.trim($(this).closest("tr").find("td:eq(4)").text()) }; */
return { "cell3": $.trim($(this).closest("tr").find("td:eq(3)").text())};//老版本
// return { "cell1": $.trim($(this).parents("tr").find("td:eq(1)").text())};//新版本
}).get();
var str="";
$.each(array, function (i, d) {undefined
str=str+d.cell3+",";
alert(d.cell3);
});
var thisForm = document.searchForm;
alert(str);
document.searchForm.action = "associatedFundSerial.action?str="+str;
document.searchForm.submit();
}
获取所有勾选的第三列的值得数组
<script src="http://code.jquery.com/jquery-1.11.0-beta1.js"></script>
欢迎关注公众号:Java后端技术全栈