这个很简单
$('tr').click(function(){
$(this).addClass("hover").siblings().removeClass("hover");
});
这样试试,只要你的hover这个样式没问题,我保证就没问题。希望可以帮到你。
$('tr').toggle(
function (){
$("tr").each(function(i,val){
$(val).removeClass('hover')
});
$(this).addClass('hover')
},
function (){
$(this).removeClass('hover')
});
不用写遍历,直接用
$('tr').toggle(
function (){
$("tr").removeClass('hover')
$(this).addClass('hover')
},
function (){
$(this).removeClass('hover')
});
$("tr").click(function(){
$(".hover").removeClass("hover");
$("this").addClass("hover");
});