table#id_table_comments tr td {
/*background: #fff;*/
background: #f5f5f5;
padding: 6px;
text-align: left;
vertical-align: top;
border-bottom:1px solid #ddd;
}
table#id_table_comments tr:nth-child(2n) td {
/*background: #f5f5f5;*/
background: #fff;
}
.classTableRow{
background-color: #9999CC;
border: 1px solid gray;
}
$(document).ready(function(){
$("td").mouseover(function(){
$(this).addClass('classTableRow');
})
$("td").mouseout(function(){
$(this).removeClass('classTableRow');
})
});
但jQuery不適用於第n行(偶數行)。jQuery幫助:如何選擇tr td第n行?
我該怎麼辦?
mouseover和mouseout有什麼問題?爲什麼我應該使用:懸停? – shibly
他們比較慢。總是最好使用CSS而不是Javascript。他們也錯了(他們泡沫);如果你真的想使用Javascript,你應該使用'mouseenter'和'mouseleave'。 – SLaks
mouseover/mouseout和mouseenter/mouseleave有什麼區別? – shibly