jquery 表格练习
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<script src="jquery-1.7.1.min.js"></script>
<script>
var list=[{'id':'1','国家':'中国','首都':'北京'},{'id':'2','国家':'美国','首都':'华盛顿'},{'id':'3','国家':'日本','首都':'东京'}]
$(function () {
var oldColor;
$.each(list, function (index, content) {
var tr = $('<tr></tr>').appendTo('tbody');
tr.hover(function () {
oldColor = $(this).css('background-color');
$(this).css({ 'background-color': 'red', 'cursor': 'pointer' });
}, function () {
$(this).css('background-color', oldColor);
});
$.each(content, function (key, value) {
$('<td>' + value + '</td>').appendTo(tr);
});
});
$('tbody tr:even').css('background-color', 'yellow');
});
</script>
</head>
<body>
<table border="1">
<thead>
<tr>
<th>Id</th>
<th>国家</th>
<th>首都</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</body>
</html>
最新文章
- CSharpGL(19)用glReadPixels把渲染的内容保存为PNG图片(C#)
- LeetCode#11. Container With Most Water
- JS中误用/g导致的正则test()无法正确重复执行
- [WPF系列]-DynamicResource与StaticResource的区别
- python %s深入解析
- 详细的图文教程来实现 eclipse环境下如何配置tomcat,并且把项目部署到Tomcat服务器上
- Exact Change(背包HDU2753)
- java读取某个文件夹下的所有文件
- 【数学相关、规律】Codeforces 696B Puzzles
- 高德地图教程_poi搜索和显示
- vuejs、eggjs全栈式开发设备管理系统
- pat1111-1120
- python3.6.4 tkinter安装
- Document APIs
- AD服务无法启动
- H5常用技巧
- Python3 tkinter基础 Menu add_cascade 多级菜单 add_separator 分割线
- poj2240
- Django开发笔记二
- Django 2.0.1 官方文档翻译: 文档目录 (Page 1)
热门文章
- 【34.25%】【BZOJ 2648】SJY摆棋子
- target属性值
- android Navigator的高度计算和推断是否显示
- 【C/C++学院】(23)Mysql数据库编程--C语言编程实现mysqlclient
- [React] Keep Application State in Sync with Browser History
- js进阶 9 js操作表单知识点总结
- 如何快糙好猛的使用libfacedetection库【最新版】
- SpringBoot集成PageHelper时出现“在系统中发现了多个分页插件,请检查系统配置!”
- Spring boot传统部署
- cordova-plugin-file-transfer 监听到下载成功,找不到文件 - 简书