1 Star 0 Fork 0

阿达/web

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
上下移动删除项.html 2.48 KB
一键复制 编辑 原始数据 按行查看 历史
阿达 提交于 2024-04-21 13:41 . wjs78
<!DOCTYPE html>
<html>
<head>
<title>上下移动和删除选项</title>
<style>
.container {
display: flex;
flex-direction: column;
gap: 10px;
}
.language-row {
display: flex;
align-items: center;
justify-content: space-between;
border: 2px solid black;
padding: 10px;
background-color: white;
}
.language {
color: black;
}
.action-buttons {
display: flex;
gap: 5px;
}
.action-button {
padding: 5px 10px;
background-color: #ccc;
border: 1px solid black;
cursor: pointer;
}
</style>
</head>
<body>
<div class="container">
<div class="language-row">
<span class="language">Java</span>
<div class="action-buttons">
<button class="action-button" onclick="moveUp(this)">上移</button>
<button class="action-button" onclick="moveDown(this)">下移</button>
<button class="action-button" onclick="deleteRow(this)">删除</button>
</div>
</div>
<div class="language-row">
<span class="language">Python</span>
<div class="action-buttons">
<button class="action-button" onclick="moveUp(this)">上移</button>
<button class="action-button" onclick="moveDown(this)">下移</button>
<button class="action-button" onclick="deleteRow(this)">删除</button>
</div>
</div>
<div class="language-row">
<span class="language">C</span>
<div class="action-buttons">
<button class="action-button" onclick="moveUp(this)">上移</button>
<button class="action-button" onclick="moveDown(this)">下移</button>
<button class="action-button" onclick="deleteRow(this)">删除</button>
</div>
</div>
</div>
<script>
// 上移操作
function moveUp(button) {
const row = button.parentNode.parentNode;
const previousRow = row.previousElementSibling;
if (previousRow) {
row.parentNode.insertBefore(row, previousRow);
}
}
// 下移操作
function moveDown(button) {
const row = button.parentNode.parentNode;
const nextRow = row.nextElementSibling;
if (nextRow) {
row.parentNode.insertBefore(nextRow, row);
}
}
// 删除操作
function deleteRow(button) {
const row = button.parentNode.parentNode;
row.parentNode.removeChild(row);
}
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/adadejiushu/web.git
git@gitee.com:adadejiushu/web.git
adadejiushu
web
web
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385