代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="http://how2j.cn/study/js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://how2j.cn/study/css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://how2j.cn/study/js/bootstrap/3.3.6/bootstrap.min.js"></script>
</head>
<body>
<table class="table">
<thead>
<th>头像</th>
<th>名字</th>
<th>HP</th>
</thead>
<tbody>
<tr>
<td><img width="20px" src="http://how2j.cn/study/bootstrap/lol/gareen.png"/></td>
<td>盖伦</td>
<td >616</td>
</tr>
<tr>
<td ><img width="20px" src="http://how2j.cn/study/bootstrap/lol/teemo.png"/></td>
<td >提莫</td>
<td >383</td>
</tr>
<tr>
<td><img width="20px" src="http://how2j.cn/study/bootstrap/lol/akali.png"/></td>
<td>阿卡丽</td>
<td>448</td>
</tr>
</tbody>
</table>
<script>
$("tr").mouseover(function(){
$("tr>td").addClass("success")
});
$("tr").mouseout(function(){
$("tr>td").removeClass("success")
});
</script>
</body>
</html>
运行如下:
鼠标移动到表格上面:
所有的都变色
我想做到的是,移动到某一行,变某一行的颜色,但是不知道如何选择单个的tr,而不是所有的tr
不知道这个应该怎么弄?
$('tr>td')选择的是全部的