var $lasttd;//上一个单元格变量
var lastcolor;//上一次颜色变量
$('.x-table td').mousemove(function(){
var tdid = $(this).attr("id");
var num=tdid.search("-"); //获取id中“-”符号第一次出现的索引
var id1=tdid.substr(0,num).replace(/[^0-9]+/ig,""); //截取id值中的行号
if(id1 != '1'){
if($lasttd){ $lasttd.parent('tr').find("td").css('background',lastcolor);} //离开后原单元格恢复原色
lastcolor=$(this).css('background-color');
if(!lastcolor)
lastcolor=$(this).css('background');//保存原始颜色
$(this).parent('tr').find("td").css('background','yellow');//设置当前单元格为红色
$lasttd=$(this);//保存上一个单元格
}
});