遇到个小意外。
问题:我的表格是 用append()动态添加的表格行,实现表格鼠标经过 行 时候高亮显示,用bind(),或者.mouseover()+.mouseout()方法不起作用
$("tr").bind("mouseover",function(){
$(this).css("background-color","#FFF");
});
$("tr").bind("mouseout",function(){
$(this).css("background-color","#000");
});
后进过查阅相关文档,得到下面的解决方案
$("table").delegate("tr","mouseover",function(){
$(this).addClass("tr-mouseover")
//$(this).css("background-color","#FC3");
});
$("table").delegate("tr","mouseout",function(){
$(this).removeClass("tr-mouseover");
//$(this).css("background-color","#FC3");
});