分析:html中的table表格是不能直接在表格中更改数据的,实现表格数据可编辑做法是在单元格中插入一个文本框,在文本框中实现数据的编辑功能,再将文本框中输入的值设置为单元格的文本值。
代码如下
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
#tab {
position: relative;
top: 20px;
left: 20px;
width: 450px;
border: 1px solid rgba(0, 0, 0, .2);
border-collapse: collapse;
}
th,
td {
width: 150px;
height: 30px;
border: 1px solid rgba(0, 0, 0, .2);
}
th {
color: #eee;
background-color: #555555;
}