隔行换色

在这里插入图片描述

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script type="text/javascript" src="img/jquery-3.4.1.js"></script>
		<script type="text/javascript">
			
			$(function(){
				$("tbody tr:even").css("background","red");
				$("tbody tr:odd").css("background","green");
				$("#div1").mousemove(function(){
					$("#div1").css("background-color","yellow");
				});
				$("#div1").mouseleave(function(){
					$("#div1").css("background-color","red");
				});
				$("#div2").mousemove(function(){
					$("#div2").css("background-color","blue");
				});
				$("#div2").mouseleave(function(){
					$("#div2").css("background-color","green");
				});
				$("#div3").mousemove(function(){
					$("#div3").css("background-color","yellow");
				});
				$("#div3").mouseleave(function(){
					$("#div3").css("background-color","red");
				});
				$("#div4").mousemove(function(){
					$("#div4").css("background-color","blue");
				});
				$("#div4").mouseleave(function(){
					$("#div4").css("background-color","green");
				});
			});
			 
		</script>
	</head>
	<body>
		<table border="1" align="center">
			<thead>
				<th>
					<div style="width: 200px;height: 30px;cursor: pointer;">
						表头
					</div>
				</th>
			</thead>
			<tbody>
			<tr>
				<td align="center">
					<div style="width: 200px;height: 30px;cursor: pointer;" id="div1">
						1
					</div>
				</td>
			</tr>
			<tr>
				<td align="center">
					<div style="width: 200px;height: 30px;cursor: pointer;" id="div2">
						2
					</div>
				</td>
			</tr>
			<tr>
				<td align="center">
					<div style="width: 200px;height: 30px;cursor: pointer;" id="div3">
						3
					</div>
				</td>
			</tr>
			<tr>
				<td align="center">
					<div style="width: 200px;height: 30px;cursor: pointer;" id="div4">
						4
					</div>
				</td>
			</tr>
			</tbody>
		</table>
	</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值