table上应用jquery的hover效果,移到tr上时,该tr给予css,在td没有合并的情况下,都是正常的,但是当td多行合并时,被合并的行不被认为是同一个tr,效果图见附件,该如何解决呢?
用tbody吧。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Untitled Document .tab{background:#FFC;border-collapse:collapse;} .tr_on{ background:#3CF;} .tr_off{ background:#FFC;} td{border:1px solid #000;} //表格奇偶背景(鼠标移上效果)////// $(function() {//定义函数 $('.tab tbody').hover( function(){ $(this).addClass("tr_on"); $(this).removeClass("tr_off"); }, function(){ $(this).addClass("tr_off"); $(this).removeClass("tr_on"); } ); });