我有一个带有复选框的gridview,我正在尝试获取单击行的复选框是否被选中。
<td>
<input type="button" id="upbutt" value="edit" />
</td><td>60</td><td>h767</td><td>itsatesthere</td><td>cat4</td><td><span class="aspNetDisabled" title="control"><input id="GridView1_ctl00_11" type="checkbox" name="GridView1$ctl13$ctl00" checked="checked" disabled="disabled" /></span></td>
<td>
<input type="button" id="upbutt" value="edit" />
</td><td>55</td><td>F309</td><td>ahmeds</td><td>cat1</td><td><span class="aspNetDisabled" title="control"><input id="GridView1_ctl00_8" type="checkbox" name="GridView1$ctl10$ctl00" disabled="disabled" /></span></td>/tr>
$(function () {
var tr = $('#GridView1').find('tr');
tr.bind('click', function (event) {
var tds = $(this).find('td:not(:first-child)');
$.each(tds, function (index, item) {
if ('#txtbadd' + (index + 1) != '#txtbadd5') {
$('#txtbadd' + (index + 1)).val(item.innerHTML);
alert($("td:has(:checkbox:checked)").text());
}
});
$("#modialog").dialog("open");
return false;
});
});
alert($("td:has(:checkbox:checked)").text());
此代码有效,但它使所有行都带有选中的复选框。我只想知道是否选中了单击的行复选框。