jquery table 隔行变色+点谁谁变色
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<meta charset="utf-8" />
<script src="jquery-3.3.1.js"></script>
<script>
$(function () {
$('#btn').click(function () {
$('#tb tr:first').css('fontSize', '30px');//第一行
$('#tb tr:last').css('color', 'red');//最后一行
$('#tb tr:gt(0):lt(3)').css('fontSize', '28px');//正文前三行
$('#tb tr:odd').css('backgroundColor', 'red');//偶数行
});
$('#tb tr').click(function () {
$(this).css('backgroundColor', 'yellow').siblings('tr').css('backgroundColor','');//点谁谁变黄色
});
});
</script>
</head>
<body>
<input type="button" name="name" value="显示效果" id="btn" />
<table border="1" id="tb" style="cursor:pointer">
<tr>
<td>姓名</td>
<td>年龄</td>
</tr>
<tr>
<td>张三</td>
<td>30</td>
</tr>
<tr>
<td>李四</td>
<td>50</td>
</tr>
<tr>
<td>王五</td>
<td>48</td>
</tr>
<tr>
<td>陈六</td>
<td>17</td>
</tr>
<tr>
<td>赵七</td>
<td>56</td>
</tr>
<tr>
<td>张八</td>
<td>98</td>
</tr>
<tr>
<td>吕九</td>
<td>20</td>
</tr>
<tr>
<td>汇总</td>
<td>600</td>
</tr>
</table>
</body>
</html>
最新文章
- CSS DIV自动适应高度
- MVC4.0
- C#Random函数在循环中每次获取一样的值
- CentOS7 PostgreSQL安装
- win7局域网里输入正确密码也访问不了其他的机器
- linux设备分类
- Eclipse执行Hadoop WordCount
- SQL Server 事务与锁
- WIN7下运行hadoop程序报:Failed to locate the winutils binary in the hadoop binary path
- onhashchange事件--司徒正美
- 3p
- (中等) UESTC 94 Bracket Sequence,线段树+括号。
- shell日志删除(超容量&;自动)
- [DeeplearningAI笔记]神经网络与深度学习人工智能行业大师访谈
- OpenGL渲染管线(rendering pipeline)
- python的高级数组之稀疏矩阵
- 域scope 介绍,及查找数据
- Solr调研总结(转)
- mybatis由浅入深day01_8输出映射_8.1resultType输出类型(8.1.1输出简单类型_8.1.2输出pojo对象和pojo列表_8.1.3输出hashmap)
- SVN提交修改时出现:Checksum mismatch