87,997
社区成员




<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
table {
font-size: 12px;
border-collapse: collapse;
border: 1px solid black;
}
table tr {
height: 20px;
line-height: 20px;
}
table tr td {
text-align: center;
width: 200px;
}
</style>
<script src="http://code.jquery.com/jquery-1.11.0-beta1.js"></script>
<script type="text/javascript">
$(function () {
$("input[type=button]").click(function () {
//获取选中的数据组
var array = $("table input[type=checkbox]:checked").map(function () {
return { "cell2": $.trim($(this).closest("tr").find("td:eq(2)").text()), "cell4": $.trim($(this).closest("tr").find("td:eq(4)").text()) };
}).get();
$.each(array, function (i, d) {
alert(d.cell2 + "|" + d.cell4);
})
})
})
</script>
</head>
<body>
<table border="1">
<tr>
<td><input type='checkbox'>
<td>
<td>1
<td>
<td>2
<td>
</tr>
<tr>
<td><input type='checkbox'>
<td>
<td>3
<td>
<td>4
<td>
</tr>
<tr>
<td><input type='checkbox'>
<td>
<td>5
<td>
<td>6
<td>
</tr>
</table>
<input type=button value='选择'>
</body>
</html>
这个可以
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src='http://code.jquery.com/jquery-1.11.0-beta1.js'></script>
</head>
<body>
<table border = "1" id='tbodyID'>
<tr>
<td><input type='checkbox' ></td>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td><input type='checkbox' ></td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td><input type='checkbox' ></td>
<td>5</td>
<td>6</td>
</tr>
</table>
<input type=button value='选择' onclick='ck()'>
<script>
function ck(){
var tbodyObj = document.getElementById('tbodyID');
$("table :checkbox").each(function(key,value){
if($(value).prop('checked')){
alert(tbodyObj.rows[key].cells[1].innerHTML);
alert(tbodyObj.rows[key].cells[2].innerHTML);
}
})
}
</script>
</body>
</html>