function getSelectedCopyDates() {
var arr = new Array();
//for every row that has a checked checkbox
$("tr").has(".noteCheckBox:checked").each(function (i) {
if ($(this).id !== "checkAllNotes"){//since this doesn't have a "abbr=..." it breaks the code below "# syntax error"
//push the value of column(FName, LName) into the array
arr.push($("#" + this.id + "> td[abbr='EventDate'] > div").text());
}
});
return arr;
}
问问题
4598 次
2 回答
3
如果通过“单元格值”您只是想在其中获取文本,<td>
那么您可以执行以下操作this
:
HTML:
<table>
<tr>
<td align="center" abbr="FName, LName">RAWR</td>
</tr>
</table>
jQuery :
$("td[abbr='FName, LName']").text();
您可以使用 jQuery 的.text()
方法来获取给定元素中的值。
编辑:
看到您只需要获取<td>
它们包含已选中复选框的 s ,因此这可能对您有用:
$("td[abbr='FName, LName'] > input:checked").parent().text();
查找所有td[abbr='FName, LName'
包含已检查输入的内容,然后获取该元素父级的文本。
//You won't need the on change event for you code. I only added it here to show you what happens when there are values and when there are no values.
$("input").on("change", function(){
var arr = new Array();
//for every row that has a checked checkbox
$("tr").has(".noteCheckBox:checked").each(function(i){
//push the value of column 5 (FName, LName) into the array
arr.push($("#"+this.id + "> td > div.c5").text());
});
//Print the array to the console.
console.log(arr);
});
编辑:
你的功能应该是:
function getSelectedInvestigatorNames() {
var arr = new Array();
//for every row that has a checked checkbox
$("tr").has(".noteCheckBox:checked").each(function(i){
//push the value of column 5 (FName, LName) into the array
arr.push($("#"+this.id + "> td[abbr='FName, LName'] > div").text());
});
return arr;
}
于 2012-10-04T20:09:25.717 回答