以本博客第二篇中的table(表头固定、左右滑动等样式)为例
var index = this.rowIndex;
var tdValue;
$("#tlist tr").click(
function() {
if(index == undefined){
$(this).css("background","yellow");
index = this.rowIndex;
tdValue = $(this).find("td");// 找到td元素
}else {
if(index == this.rowIndex){
$(this).css("background","#ffffff");
index = undefined;
}else{
$(this).css("background","yellow").siblings().css("background","#ffffff");
index = this.rowIndex;
}
}
});
tdValue[0].innerHTML;//即为选中行第一个元素值
效果图:(只是单选)