<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="../jquery-1.12.2.min.js"></script>
</head>
<body>
<table width="234" height="77" border="1">
<tr align="center" id="tr1" onMouseOver="over(this.id)" onMouseOut="out(this.id)">
<td width="52"> </td>
<td width="65">商品</td>
<td width="95">价格(元)</td>
</tr>
<tr align="center" id="tr2" onMouseOver="over(this.id)" onMouseOut="out(this.id)">
<td>A商场</td>
<td>S商品</td>
<td>100</td>
</tr>
<tr align="center" id="tr3" onMouseOver="over(this.id)" onMouseOut="out(this.id)">
<td>B商场</td>
<td>S商品</td>
<td>80</td>
</tr>
</table>
<script>
function over(trname){
console.log("over")
$(trname).css({background:"#0000FF",color:"#FFFFFF"})
//eval(trname).style.backgroundColor="0000FF";
//eval(trname).style.color="FFFFFF";
}
function out(trname){
console.log("out")
eval(trname).style.backgroundColor="FFFFFF";
eval(trname).style.color="000000";
}
</script>
</body>
</html>
4 回答
午后苦咖啡
TA贡献3条经验 获得超1个赞
<script>
function over(trname){
console.log("over")
$("#"+trname).css({background:"#0000FF",color:"#FFFFFF"}) ;
}
function out(trname){
console.log("out")
$("#"+trname).css({background:"#fff",color:"#000"});
}
</script>
瘦驼
TA贡献3条经验 获得超1个赞
jquery选择器和css选择器一致,少了“#”。
$("#"+trname).css({"background-color":"#00F","color":"#FFF"});
- 4 回答
- 0 关注
- 1582 浏览
相关问题推荐
添加回答
举报
0/150
提交
取消