html JS.HTML.CSS.Tables.A典型的HTML table.v2

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html JS.HTML.CSS.Tables.A典型的HTML table.v2相关的知识,希望对你有一定的参考价值。

table {
  width:100%;
  border:1px solid;
  border-collapse: collapse;
}


tr, th, td {
  border:1px solid;
  font-family:courier;
}

td {
  text-align:center;
  padding:10px;
  
}
function borderCollapse() {
  var table = document.querySelector("table");
  
  table.style.borderCollapse = "collapse";
}

function insertRow() {
  var table = document.querySelector("#myTable");
  
  // without parameters, insert at the end,
  // otherwise parameter = index where the row will be inserted
  var row = table.insertRow();
  
  var cell1 = row.insertCell();
  cell1.innerHTML = "New cell1";
  var cell2 = row.insertCell();
  cell2.innerHTML = "New cell2";
  var cell3 = row.insertCell();
  cell3.innerHTML = "New cell3";
}

function deleteFirstRow() {
  var table = document.querySelector("#myTable");
  table.deleteRow(1); // 0 is the header
}
JS.HTML.CSS.Tables.A Typical HTML table.v2
------------------------------------------


A [Pen](https://codepen.io/Onlyforbopi/pen/dqxwRo) by [Pan Doul](https://codepen.io/Onlyforbopi) on [CodePen](https://codepen.io).

[License](https://codepen.io/Onlyforbopi/pen/dqxwRo/license).
JS.HTML.CSS.A Typical HTML table.v2
-----------------------------------


A [Pen](https://codepen.io/Onlyforbopi/pen/dqxwRo) by [Pan Doul](https://codepen.io/Onlyforbopi) on [CodePen](https://codepen.io).

[License](https://codepen.io/Onlyforbopi/pen/dqxwRo/license).
<!DOCTYPE html> 
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>A typical HTML table with simple styling</title>
</head>
<body>
<table id="myTable">
 <caption>A typical HTML table</caption>  
  <tr>
    <th scope="col">Given Name</th>
    <th scope="col">Family Name</th> 
    <th scope="col">Age</th>
  </tr>
  <tr>
    <td>Michel</td>
    <td>Buffa</td> 
    <td>52</td>
  </tr>
  <tr>
    <td>Dark</td>
    <td>Vador</td> 
    <td>Unknown</td>
  </tr>
    <tr>
    <td>Luke</td>
    <td>Skywalker</td> 
    <td>Unknown</td>
  </tr>
</table>
  <p>Click to add a new row</p>
  <button onclick="insertRow();">Add a new row</button>
  <p>Click to delete the first row of the table</p>
  <button onclick="deleteFirstRow();">Delete first row</button>
</body>
</html>

以上是关于html JS.HTML.CSS.Tables.A典型的HTML table.v2的主要内容,如果未能解决你的问题,请参考以下文章

Html.Partial 与 Html.RenderPartial 和 Html.Action 与 Html.RenderAction

html Html模板/ Html Boilerplate |标签HTML

html里怎么引用一个html的头部

html5与传统html区别

html4和html5的区别

HTML元素