| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title></title>
- <style>
- #data {
- border-collapse: collapse;
- }
- #data td, #data th {
- width: 120px;
- height: 40px;
- text-align: center;
- border: 1px solid black;
- }
- #buttons {
- margin: 10px 0;
- }
- </style>
- </head>
- <body>
- <table id="data">
- <caption>数据统计表</caption>
- <tr>
- <th>姓名</th>
- <th>年龄</th>
- <th>性别</th>
- <th>身高</th>
- <th>体重</th>
- </tr>
- <tr>
- <td>Item1</td>
- <td>Item2</td>
- <td>Item3</td>
- <td>Item4</td>
- <td>Item5</td>
- </tr>
- <tr>
- <td>Item1</td>
- <td>Item2</td>
- <td>Item3</td>
- <td>Item4</td>
- <td>Item5</td>
- </tr>
- <tr>
- <td>Item1</td>
- <td>Item2</td>
- <td>Item3</td>
- <td>Item4</td>
- <td>Item5</td>
- </tr>
- <tr>
- <td>Item1</td>
- <td>Item2</td>
- <td>Item3</td>
- <td>Item4</td>
- <td>Item5</td>
- </tr>
- <tr>
- <td>Item1</td>
- <td>Item2</td>
- <td><a>Item3</a></td>
- <td>Item4</td>
- <td>Item5</td>
- </tr>
- <tr>
- <td>Item1</td>
- <td>Item2</td>
- <td>Item3</td>
- <td>Item4</td>
- <td><a>Item5</a></td>
- </tr>
- </table>
- <div id="buttons">
- <button id="pretty">美化表格</button>
- <button id="clear">清除数据</button>
- <button id="remove">删单元格</button>
- <button id="hide">隐藏表格</button>
- </div>
- <script src="js/jquery.min.js"></script>
- <script>
- $(function() {
- $("#pretty").on("click", function() {
- $("#data tr:gt(0)").css("color", "white");
- $("#data tr:odd").css("background-color", "darkgreen");
- $("#data tr:even").css("background-color", "darkmagenta");
- $("#data tr:eq(0)").css("background-color", "white");
- });
- $("#clear").on("click", function() {
- $("#data tr:gt(0) td").html("");
- });
- $("#remove").on("click", function() {
- $("#data tr:gt(0):last").remove();
- });
- $("#hide").on("click", function() {
- $("#data").fadeOut(2000, function() {
- $("#data").css({
- "display": "block",
- "visibility": "hidden"
- });
- });
- });
- });
- </script>
- </body>
- </html>
|