使用js实现 表的 “增删改查上下移动” 功能

在这里插入图片描述
要实现图片中的的效果,废话不多说直接上代码
html代码

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" type="text/css" href="data.css">
</head>
<body>
  <div>
  //所需要的添加栏
    <form method="post" class="form">
      <span>姓名</span><input type="text" /><br />
      <span>年龄</span><input type="text" /><br />
      <span>性别</span><input type="text" /><br />
      <span>学号</span><input type="text" /><br />
      <p><button type="button" class="addBtn LanEdit" onclick="addEle()">添加</button></p>
      <p><button type="button" class="addBtn LanSave" onclick="updateEle2()">保存</button></p>
    </form>
  
  </div>
  //查询框
  <div class="seach">
    <input type="text" class="seachText" /><button type="button" class="seachClick" onclick="seachData()">查询</button>
  </div>
  //表格
  <table id="tab">
    <tr>
      <td>序号</td>
      <td>姓名</td>
      <td>年龄</td>
      <td>性别</td>
      <td>学号</td>
      <td>操作</td>
      <td>移动</td>
    </tr>        
  </table>



</body>
<script src="data01.js"></script>
<!-- // 当添加栏点击保存时,
        //1、添加按钮变成保存按钮,保存以后再次变回添加按钮
        //2、列表栏数据改变
        //3、存储的数据改变
        //4、操作的保存改成编辑
-->
</html>

css代码

* {
   
  padding: 0;
  margin: 0;
}

div {
   
  width: 300px;
  height: 300px;
  background-color: antiquewhite;
  display: inline-block;
  margin: 20px;
}

span {
   
  margin: 10px;
}

input {
   
  width: 200px;
  height: 30px;
  margin: 10px;
}

.addBtn {
   
  width: 90px;
  height: 30px;
  margin-left: 100px;
  margin-top: 20px;
  background-color: coral;
  color: #fff;
  border: none;
  cursor: pointer;
}

#tab {
     
  display: inline-block;
  width: 70%;
  height: 300px;
  position: absolute;
  left: 500px;
  margin-top: 70px;
}

#tab tr td {
     
  display: inline-block;
  min-width: 90px;
  height: 30px;
  line-height
  • 5
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值