目前我得到该行的所有输出。是否有可能只获取所选“点”的值。我怎样才能做到这一点?如何通过JQuery中的复选框获取所选列的值?
检查时所预期的输出: SF01 SF02 SF03
检查时,电流输出: SF01 11.5 3.5328 120.3359
<table border="1" width="100%" id="selectTable" name="selectTable">
<legend>Display Data Points</legend>
<tr>
<th></th>
<th width="40%">Point</th>
<th width="20%">Depth</th>
<th width="20%">Lat</th>
<th width="20%">Long</th>
</tr>
<tr>
<td>
<input type="checkbox" class="checkBox" name="checkBox[]" />
</td>
<td>SF01</td>
<td>11.5</td>
<td>3.5328</td>
<td>120.3359</td>
</tr>
<tr>
<td>
<input type="checkbox" class="checkBox" name="checkBox[]" />
</td>
<td>SF02</td>
<td>41.5</td>
<td>6.5328</td>
<td>113.3359</td>
</tr>
<tr>
<td>
<input type="checkbox" class="checkBox" name="checkBox[]" />
</td>
<td>SF03</td>
<td>82.1</td>
<td>5.2828</td>
<td>721.9059</td>
</tr>
</table>
<script type="text/javascript">
function clickedBox() {
var values = new Array();
$.each($("input[name='checkBox[]']:checked").closest("td").siblings("td"), function() {
values.push($(this).text());
});
document.getElementById("boxArea").value = "=====Results=====\n" + values.join("\n");
}
$(document).ready(function() {
$("#selectPoint").click(clickedBox);
});
</script>
与HTML相比预期输出的例子,看来你的意思是你想从一个特定的列得到vlaues,而不是行?如果是这样,请编辑您的问题,以便意义明显。否则,你需要提供更多的说明。 –
这里'#selectPoint'的元素是什么? –
加入'ready','$(':checkbox [name =“checkBox []”]')。change(clickedBox);' – Tushar