嗨,我是新來的JavaScript和jquery.I只是想知道是否有使用這種格式選擇表數據的任何一個表中的數據:選擇使用javascript/jQuery的
$("#myTable").row[index1][index2];
這裏索引1是排索引,索引2是列。類似的事情也很好。
嗨,我是新來的JavaScript和jquery.I只是想知道是否有使用這種格式選擇表數據的任何一個表中的數據:選擇使用javascript/jQuery的
$("#myTable").row[index1][index2];
這裏索引1是排索引,索引2是列。類似的事情也很好。
試試這個:你可以使用.eq()在jQuery來遍歷tr
和td
與指定索引
var td = $("#myTable").find('tr:eq('+index1+')').find('td:eq('+index2+')');
var data = $(td).text();// you can use .html() if you need html inside td
試試這個:
$(function(){
$('input').click(function()
{
var t= $(this).attr('class');
var text= $('.time'+t).text();
alert(text);
});
$('td').click(function()
{
var index = this.cellIndex;
alert($('tr:first').find('td').eq(index).text());
});
});
它會遍歷你的表格單元格並打印數值 -
$("#myTable>tr>td").each(function() {
var cell_value = $(this).html();
alert(cell_value);
})
什麼是你的表格的html代碼?你的行和列是否有標識符? – andrex 2014-09-24 04:46:38